在phantomjs-prebuilt@2.1.13安装脚本' node install.js'

时间:2016-12-06 09:44:23

标签: node.js phantomjs

我正在尝试在Windows 7计算机上安装phantomjs并收到此错误。

npm ERR! Windows_NT 6.1.7601  
npm ERR! argv "C:\\Program Files (x86)\\nodist\\v\\nodev5.5.0\\node.exe"   "C:\\Program Files (x86)\\nodist\\bin\\node_mod  
ules\\npm\\bin\\npm-cli.js" "install"  
npm ERR! node v5.5.0  
npm ERR! npm  v3.10.9  
npm ERR! code ELIFECYCLE  

npm ERR! phantomjs-prebuilt@2.1.13 install: `node install.js`  
npm ERR! Exit status 1  
npm ERR!  
npm ERR! Failed at the phantomjs-prebuilt@2.1.13 install script 'node   install.js'.  
npm ERR! Make sure you have the latest version of node.js and npm installed.

phantomjs github repo中针对相同或this SO问题记录了许多问题,但在我的案例中没有任何问题有帮助。

这就是我机器的状态

  • 我在 C:\ npm \ phantomjs-2.1.1-windows \ bin \ phantomjs.exe 本地安装了phantomjs但是当我运行npm install时,它总会尝试通过下载安装这对我来说是个问题。我的公司代理阻止直接下载。我也无法使用此处提到的--phantomjs_cdnurl开关https://www.npmjs.com/package/phantomjs#deciding-where-to-get-phantomjs
  • 我可以运行命令,它运行正常     phantomjs -v
    2.1.1

但是当我在我的项目上运行npm install时,它正在尝试安装phantomjs并将遇到上述错误。我从npm日志中观察到的另一件事

Considering PhantomJS found at C:\Program Files (x86)\nodist\bin\phantomjs.CMD Found PhantomJS at C:\Program Files (x86)\nodist\bin\phantomjs.CMD ...verifying Error verifying phantomjs, continuing { [Error: Command failed: C:\Program Files (x86)\nodist\bin\phantomjs.CMD --version

它试图运行phantomjs.CMD --version也失败了

Error verifying phantomjs, continuing { [Error: Command failed: C:\Program Files (x86)\nodist\bin\phantomjs.CMD --versio
n
internal/child_process.js:274
  var err = this._handle.spawn(options);
                         ^

TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (internal/child_process.js:274:26)
    at exports.spawn (child_process.js:362:9)
    at Object.<anonymous> (C:\Program Files (x86)\nodist\bin\node_modules\phantomjs-prebuilt\bin\phantomjs:22:10)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:139:18)
]
  killed: false,
  code: 1,
  signal: null,
  cmd: 'C:\\Program Files (x86)\\nodist\\bin\\phantomjs.CMD --version' }

3 个答案:

答案 0 :(得分:10)

作为临时工作,我可以使用--ignore-scripts

安装它

npm install phantomjs-prebuilt@2.1.13 --ignore-scripts

我还在github repo中记录了同一个

的问题

https://github.com/Medium/phantomjs/issues/649

编辑

这个问题是我正在使用的构建过程脚本的一部分,它执行npm清理并且每次都安装了许多其他东西。因此,这个问题在我们使用phantomjs进行自动化测试的同一台机器中多次出现。我有时间研究这个问题,似乎我的公司代理阻止了https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-windows.zip的下载。我以前知道这个并且手动安装了phantomjs二进制文件并添加到系统路径但是npm安装仍然尝试在本地下载,如下面的日志所示。

Considering PhantomJS found at C:\npm\phantomjs-2.1.1-windows\bin\phantomjs.EXE
Looks like an `npm install -g` on windows; skipping installed version.

我的公司代理也阻止了所有phantomjs CDN网址(https://www.npmjs.com/package/phantomjs

我使用的工作是获取 phantomjs-2.1.1-windows.zip 并将其复制到 C:\ Users \&lt; username&gt; \ AppData \ Local \ Temp \ phantomjs \ phantomjs-2.1.1-windows.zip 并解决了构建脚本的问题。如果有人清理临时目录,问题就会回来。即使这是一种解决方法,但由于显而易见的原因,公司代理无法解除阻止:)

希望这有助于某人!

答案 1 :(得分:1)

有时,当我们尝试在本地安装phantomjs时,它将起作用。但是对于全局,我建议您键入

sudo npm install -g phantomjs-prebuilt --unsafe-perm

答案 2 :(得分:0)

我遇到了相同的错误,它将通过以下更改来解决,希望对您有所帮助。

sudo npm install phantomjs-prebuilt@2.1.13 --unsafe-perm
相关问题