Installation 在Mac上安装PhantomJS
我正试图在我的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
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
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