【问题标题】:Error installing PhantomJS with NPM / NodeJS使用 NPM / NodeJS 安装 PhantomJS 时出错
【发布时间】:2020-06-12 14:41:00
【问题描述】:

我最近无法在我的 Vagrant Box 中安装 PhantomJS。 “npm install 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']

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

“完整的 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

【问题讨论】:

  • 您能否提供一份您的 Vagrantfile 的副本,或者至少是重现此问题的最小版本?
  • 我现在使用的是旧版本的 PhantomJS,它可以工作。

标签: node.js npm phantomjs vagrant


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    我想在 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 安装即可。

    【讨论】:

      【解决方案3】:

      我知道这是一个较老的问题,但我在上次发布的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 以及所有的包装器。

      【讨论】:

        猜你喜欢
        • 2014-02-17
        • 2016-06-05
        • 2018-06-23
        • 1970-01-01
        • 2015-02-01
        • 1970-01-01
        • 2015-07-17
        • 2015-01-15
        • 2020-01-28
        相关资源
        最近更新 更多