当我执行casperjs时,它抛出一个TypeError:
#casperjs test.js
child_process.js:936
var r = this._handle.spawn(options);
^
TypeError: Bad argument
at ChildProcess.spawn (child_process.js:936:24)
at exports.spawn (child_process.js:736:9)
at Object.<anonymous> (/usr/local/lib/node_modules/phantomjs/bin/phantomjs:22:10)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
并且没有test.js它会抛出相同的错误:
# casperjs
child_process.js:936
var r = this._handle.spawn(options);
^
TypeError: Bad argument
at ChildProcess.spawn (child_process.js:936:24)
at exports.spawn (child_process.js:736:9)
at Object.<anonymous> (/usr/local/lib/node_modules/phantomjs/bin/phantomjs:22:10)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
使用以下命令安装了casperjs,请参阅http://docs.casperjs.org/en/latest/installation.html#installing-from-npm:
$ npm install -g casperjs
如果有人可以提供帮助,请提前多多感谢。
答案 0 :(得分:3)
发现问题来自phantomjs:
#phantomjs hello.js
child_process.js:936
var r = this._handle.spawn(options);
^
TypeError: Bad argument
at ChildProcess.spawn (child_process.js:936:24)
at exports.spawn (child_process.js:736:9)
at Object.<anonymous> (/usr/local/lib/node_modules/phantomjs/bin/phantomjs:22:10)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
重新安装phantomjs之后问题就消失了:
npm install -g phantomjs
CDN网站:
PHANTOMJS_CDNURL=http://cnpmjs.org/downloads npm install -g phantomjs
phantomjs和casperjs都是正确的:
# phantomjs -v
1.9.8
# phantomjs hello.js
Hello, world!
#casperjs test.js
百度一下,你就知道
根本原因似乎是之前安装了一个破碎的phantomjs,当执行phantomjs时它会导致破坏的版本。
谢谢你们提出问题。 希望这个expierence将帮助他人。
最诚挚的问候 -Radon