Encounter TypeError with casperjs

when I execute casperjs it throws a 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

and without test.js it causes the same error:

# 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 was installed with the following command: http://docs.casperjs.org/en/latest/installation.html#installing-from-npm :

$ npm install -g casperjs 

Thanks in advance if anyone can help with this.

+4
source share
1 answer

Phantomjs issue detected:

#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

after reinstalling phantomjs the problem disappeared:

npm install -g phantomjs

CDN website:

PHANTOMJS_CDNURL=http://cnpmjs.org/downloads npm install -g phantomjs

Both phantomjs and casperjs go right:

# phantomjs -v
1.9.8
# phantomjs hello.js 
Hello, world!
#casperjs test.js               
百度一下,你就知道

, -, , phantomjs , phantomjs .

, , . .

-

+3

Source: https://habr.com/ru/post/1609348/


All Articles