简体   繁体   English

使用 NPM / NodeJS 安装 PhantomJS 时出错

[英]Error installing PhantomJS with NPM / NodeJS

I recently cannot install PhantomJS anymore inside of my Vagrant Box.我最近无法在 Vagrant Box 中安装 PhantomJS。 "npm install phantomjs" fails. “npm install phantomjs”失败。

When i check the extracted folder after the installation fails in "/tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-...", the folder is empty.当我在“/tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-...”中检查安装失败后提取的文件夹时,该文件夹为空。 The results is:结果是:

[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']

So it seems that the installation script has some problems extracting the sources (maybe).因此,安装脚本似乎在提取源代码时存在一些问题(可能)。 Has anybody run into the same problem and solved it?有没有人遇到同样的问题并解决了它? I need to have PhantomJS installed with "npm install" - so manual downloading would not be an option.我需要使用“npm install”安装 PhantomJS - 所以手动下载不是一种选择。 Thanks!谢谢!

"full npm install" output: “完整的 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

Ok my "solution" is that I include PhantomJS now in version "1.9.10", which downloads a prior version from bitbucket in the background and doesn't result in the described error.好的,我的“解决方案”是我现在在版本“1.9.10”中包含 PhantomJS,它在后台从 bitbucket 下载以前的版本,并且不会导致所描述的错误。 So for me it seems that there is a problem in the current version of the PhantomJS install script for NPM.所以对我来说,当前版本的 NPM 的 PhantomJS 安装脚本似乎存在问题。

I'd like to add a solution on windows system.我想在 Windows 系统上添加一个解决方案。 I hope people may find similarities between the problem and some might seek a solution for windows.我希望人们可以找到问题之间的相似之处,有些人可能会寻求 Windows 的解决方案。

I also fails at npm install phantomjs.我在 npm install phantomjs 上也失败了。 My problem is I can't download the phantomjs-2.1.1-windows.zip file into the temp file when I install by npm or yarn.我的问题是当我通过 npm 或 yarn 安装时,我无法将 phantomjs-2.1.1-windows.zip 文件下载到临时文件中。 The error log has a bunch of distraction like can't do command node ./install , which doesn't help solving the problem.错误日志有一堆干扰,比如can't do command node ./install ,这无助于解决问题。

My solution was to download the zip file myself, direct into \\AppData\\Local\\Temp\\phantomjs and put the zip file there, the next install by yarn works.我的解决方案是自己下载 zip 文件,直接进入\\AppData\\Local\\Temp\\phantomjs并将 zip 文件放在那里,接下来通过 yarn 安装即可。

I know this is an older question, but I experienced same kind of issue with last published version of this wrapper of version 2 , specifically for 2.1.1.我知道这是一个较旧的问题,但我在版本 2这个包装器的最新发布版本中遇到了同样的问题,特别是对于 2.1.1。 So I tried to use another mirror, exposed in the official documentation with this command, and it worked:所以我尝试使用另一个镜像, 在官方文档中使用此命令公开,并且它起作用了:

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

By the way, PhantomJS is deprecated and all the wrappers too.顺便说一句, PhantomJS 已被弃用,所有包装器也已弃用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM