【发布时间】:2016-12-06 09:44:23
【问题描述】:
我正在尝试在 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 存储库中记录了许多相同或 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' }
【问题讨论】: