Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Installation 在Mac上安装PhantomJS_Installation_Phantomjs_Casperjs - Fatal编程技术网

Installation 在Mac上安装PhantomJS

Installation 在Mac上安装PhantomJS,installation,phantomjs,casperjs,Installation,Phantomjs,Casperjs,我正试图在我的Mac(约塞米蒂)上安装PhantomJS 我做了以下工作: npm install phantomjs 然后我做了: npm install phantomjs-prebuilt 这两者都出现在“我的节点”模块中。但是当我尝试运行phantomjs--version时,我得到了 -bash: phantomjs: command not found 还尝试从下载网站安装二进制文件,但没有。我错过了什么?最终目标是使用casperjs,但目前casper正在询问 Fat

我正试图在我的Mac(约塞米蒂)上安装PhantomJS

我做了以下工作:

npm install phantomjs
然后我做了:

npm install phantomjs-prebuilt
这两者都出现在“我的节点”模块中。但是当我尝试运行phantomjs--version时,我得到了

   -bash: phantomjs: command not found
还尝试从下载网站安装二进制文件,但没有。我错过了什么?最终目标是使用casperjs,但目前casper正在询问

Fatal: [Errno 2] No such file or directory; did you install phantomjs?

我以为我是

您需要将phantomjs二进制文件添加到路径中。您可以通过修改环境变量或将二进制文件符号链接到例如
/usr/local/bin

例如,如果要对二进制文件进行符号链接:

cd $HOME
curl -O https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip
ln -s $HOME/phantomjs-2.1.1-macosx/bin/phantomjs /usr/bin/phantomjs
或者,如果要修改PATH环境变量:

cd $HOME
curl -O https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip
并将此行添加到此文件:
~/.bash\u profile

export PATH=$HOME/phantomjs-2.1.1-macosx/bin:$PATH
然后运行:

source ~/.bash_profile
  • 从下载phantomjs最新版本(例如:phantomjs-2.1.1-macosx.zip)
  • 将其解压缩到某个路径(例如:~/Desktop/phantomjs-2.1.1-macosx)
  • 在终端上运行此命令- sudo ln-n~/Desktop/phantomjs-2.1.1-macosx/bin/phantomjs/usr/local/bin/
  • 通过命令phantomjs从终端启动phantomjs
  • 通过命令检查phantomjs版本:phantomjs-v
  • 通过命令检查phantomjs路径:哪个phantomjs
  • 如果正在使用,则可以键入:

    brew tap homebrew/cask
    brew cask install phantomjs
    

    您不应该在全球范围内安装
    phantomjs

    npm安装-g phantomjs

    由于是在本地安装,因此命令-

    phantomjs-v

    不会在任何地方都起作用


    您可以在此处查看本地安装和全局安装之间的差异:

    经过大量挖掘,我发现在High Sierra旧版本的phantomjs上(接受的答案已经过时。在Mac上,使用自制,键入:

    brew tap homebrew/cask
    brew cask install phantomjs
    
    对于某些MacOS版本,第一步可能不是必需的

    对于较新版本的cask(2021年及更高版本),请使用

    麦克·比格瑟

    brew tap homebrew/cask
    brew install --cask phantomjs
    

    为什么他们不制作一个合适的安装程序呢?同样适用于windows。PITA for newcomersI无法解压
    phantomjs-2.1.1-macosx.zip
    @GodraudeHas有人下载并解压了最新的macosx phantomjs包吗?你救了我。它已从homebrew/core迁移到homebrew/cask。你可以通过运行:brew tap再次访问它自制/cask,然后您可以通过运行来安装它:brew cask install phantomjs它提醒我使用
    brew安装--cask phantomjs
    。首先它要求>brew点击自制/cask>,然后是您的答案。至少对于High Sierra和Mojave。这里是cask的更新版本。brew安装--cask phantomjs
    brew tap homebrew/cask
    brew install --cask phantomjs