使用 casperjs 遇到 TypeError
Encounter TypeError with casperjs
当我执行 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
如果有人可以提供帮助,请提前致谢。
发现问题来自 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 时它会获取损坏的版本。
感谢大家提出问题。
希望这个经验对其他人有帮助。
最好的问候
-氡
当我执行 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
如果有人可以提供帮助,请提前致谢。
发现问题来自 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 时它会获取损坏的版本。
感谢大家提出问题。 希望这个经验对其他人有帮助。
最好的问候 -氡