使用NPM / NodeJS安装PhantomJS时出错

时间:2015-02-18 09:09:36

标签: node.js npm phantomjs vagrant

我最近无法在我的Vagrant Box中安装PhantomJS。 " npm安装phantomjs"失败。

当我在" /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract -..."中安装失败后检查解压文件夹时,该文件夹是空。结果是:

[exec] Copying extracted folder /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-1424249772389/phantomjs-1.9.8-linux-x86_64 -> /vagrant/project/node_modules/phantomjs/lib/phantom
[exec] Phantom installation failed { [Error: ENOTDIR, not a directory '/vagrant/project/node_modules/phantomjs/lib/phantom/bin/phantomjs']

因此,似乎安装脚本在提取源(可能)时遇到一些问题。有没有人遇到同样的问题并解决了它?我需要安装PhantomJS" npm install" - 所以手动下载不是一个选择。谢谢!

"完整的npm安装"输出:

 [exec] > phantomjs@1.9.15 install /vagrant/project/node_modules/phantomjs
 [exec] > node install.js
 [exec]
 [exec] Downloading https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
 [exec] Saving to /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2
 [exec] Using proxy http://127.0.0.1:8080/
 [exec] Receiving...
 [exec]
 [exec] Received 12854K total.
 [exec] Extracting tar contents (via spawned process)
 [exec] Removing /vagrant/project/node_modules/phantomjs/lib/phantom
 [exec] Copying extracted folder /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-1424249772389/phantomjs-1.9.8-linux-x86_64 -> /vagrant/project/node_modules/phantomjs/lib/phantom
 [exec] Phantom installation failed { [Error: ENOTDIR, not a directory '/vagrant/project/node_modules/phantomjs/lib/phantom/bin/phantomjs']
 [exec]   errno: 27,
 [exec]   code: 'ENOTDIR',
 [exec]   path: '/vagrant/project/node_modules/phantomjs/lib/phantom/bin/phantomjs',
 [exec]   syscall: 'chmod' } Error: ENOTDIR, not a directory '/vagrant/project/node_modules/phantomjs/lib/phantom/bin/phantomjs'
 [exec]     at Object.fs.chmodSync (evalmachine.<anonymous>:833:18)
 [exec]     at Object.chmodSync (/vagrant/project/node_modules/phantomjs/node_modules/fs-extra/node_modules/graceful-fs/polyfills.js:141:17)
 [exec]     at Promise.validExit [as _successFn] (/vagrant/project/node_modules/phantomjs/install.js:145:8)
 [exec]     at Promise._call (/vagrant/project/node_modules/phantomjs/node_modules/kew/kew.js:373:13)
 [exec]     at Promise._withInput (/vagrant/project/node_modules/phantomjs/node_modules/kew/kew.js:333:25)
 [exec]     at Promise.resolve (/vagrant/project/node_modules/phantomjs/node_modules/kew/kew.js:105:27)
 [exec]     at resolver (/vagrant/project/node_modules/phantomjs/node_modules/kew/kew.js:409:17)
 [exec]     at CB (/vagrant/project/node_modules/phantomjs/node_modules/fs-extra/node_modules/rimraf/rimraf.js:68:5)
 [exec]     at Object.oncomplete (fs.js:108:15)
 [exec] npm ERR! Linux 3.10.0-123.el7.x86_64
 [exec] npm ERR! argv "node" "/usr/bin/npm" "install"
 [exec] npm ERR! node v0.10.36
 [exec] npm ERR! npm  v2.1.5
 [exec] npm ERR! code ELIFECYCLE
 [exec]
 [exec] npm ERR! phantomjs@1.9.15 install: `node install.js`
 [exec] npm ERR! Exit status 1
 [exec] npm ERR!
 [exec] npm ERR! Failed at the phantomjs@1.9.15 install script.
 [exec] npm ERR! This is most likely a problem with the phantomjs package,
 [exec] npm ERR! not with npm itself.
 [exec] npm ERR! Tell the author that this fails on your system:
 [exec] npm ERR!     node install.js
 [exec] npm ERR! You can get their info via:
 [exec] npm ERR!     npm owner ls phantomjs
 [exec] npm ERR! There is likely additional logging output above.
 [exec] Writing location.js file
 [exec] npm ERR! Linux 3.10.0-123.el7.x86_64
 [exec] npm ERR! argv "node" "/usr/bin/npm" "install"
 [exec] npm ERR! node v0.10.36
 [exec] npm ERR! npm  v2.1.5
 [exec] npm ERR! path npm-debug.log.a2a87417fd31c590abbf00d595ab39a5
 [exec] npm ERR! code ETXTBSY
 [exec] npm ERR! errno 62
 [exec]
 [exec] npm ERR! ETXTBSY, rename 'npm-debug.log.a2a87417fd31c590abbf00d595ab39a5'
 [exec] npm ERR!
 [exec] npm ERR! If you need help, you may report this error at:
 [exec] npm ERR!     <http://github.com/npm/npm/issues>
 [exec]
 [exec] npm ERR! Please include the following file with any support request:
 [exec] npm ERR!     /vagrant/project/npm-debug.log

3 个答案:

答案 0 :(得分:0)

好的我的&#34;解决方案&#34;是我现在在版本&#34; 1.9.10&#34;中包含PhantomJS,它在后台下载bitbucket的先前版本并且不会导致所描述的错误。所以对我来说,似乎NPM的PhantomJS安装脚本的当前版本存在问题。

答案 1 :(得分:0)

我想在Windows系统上添加一个解决方案。我希望人们可能会发现问题之间的相似之处,有些人可能会寻求Windows的解决方案。

我也在npm install phantomjs失败了。我的问题是当我通过npm或yarn安装时,我无法将phantomjs-2.1.1-windows.zip文件下载到临时文件中。错误日志有一些像can't do command node ./install这样的分心,这无助于解决问题。

我的解决方案是自己下载zip文件,直接下载到\AppData\Local\Temp\phantomjs并将zip文件放在那里,下一次安装由yarn工作。

答案 2 :(得分:0)

我知道这是一个较旧的问题,但是我遇到的this wrapper of version 2的最新发布版本(特别是针对2.1.1)存在相同的问题。因此,我尝试将此命令与另一个镜像exposed in the official documentation配合使用,并且有效:

npm install --global phantomjs --phantomjs_cdnurl=http://cnpmjs.org/downloads

顺便说一下,PhantomJS is deprecated以及所有包装器。

相关问题