Node.js 卡斯珀斯:“;TypeError:casper.on不是函数”;

Node.js 卡斯珀斯:“;TypeError:casper.on不是函数”;,node.js,casperjs,Node.js,Casperjs,我的代码非常简单: let casper = require('casper').create({ pageSettings: { loadImages: false, loadPlugins: false, userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4'

我的代码非常简单:

let casper = require('casper').create({
  pageSettings: {
    loadImages:  false,
    loadPlugins: false,
    userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4'
  }
});

casper.on("page.error", (msg, trace) => {
  this.echo("Page Error: " + msg, "ERROR");
});

casper.on("resource.received", (resource) => {
  console.log('***', resource);
});

casper.start('https://my-app.com/');

casper.then(() => {
  this.test.assertExists('#login-form', 'Form is found');
  this.fill('#login-form', {
    'user-email': 'user@mailcom',
    'pin-number': '1234',
  }, true);
});

casper.run();
当我使用
节点test.js运行时,我得到下一个错误:

WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
Login...
E:\app\test.js:32
    casper.on("page.error", (msg, trace) => {
           ^

TypeError: casper.on is not a function
    at login (E:\Proyectos\btc-watcher\app\test.js:32:12)
    at Object.<anonymous> (E:\Proyectos\btc-watcher\app\test.js:61:3)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Eduardo\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
npm ERR! node v6.10.0
npm ERR! npm  v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! btc-watcher@ test: `node --debug=5858 test.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the btc-watcher@ test script 'node --debug=5858 test.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the btc-watcher package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node --debug=5858 test.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs btc-watcher
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls btc-watcher
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Eduardo\AppData\Roaming\npm-cache\_logs\2017-03-04T01_36_28_318Z-debug.log
警告:请参阅https://github.com/lorenwest/node-config/wiki/Strict-Mode
登录。。。
E:\app\test.js:32
casper.on(“page.error”(消息,跟踪)=>{
^
TypeError:casper.on不是函数
登录时(E:\Proyectos\btc watcher\app\test.js:32:12)
at对象。(E:\Proyectos\btc watcher\app\test.js:61:3)
在模块处编译(Module.js:570:32)
在Object.Module.\u extensions..js(Module.js:579:10)
在Module.load(Module.js:487:32)
在tryModuleLoad时(module.js:446:12)
在Function.Module.\u加载(Module.js:438:3)
位于Module.runMain(Module.js:604:10)
运行时(bootstrap_node.js:394:7)
启动时(bootstrap_node.js:149:9)
在bootstrap_node.js:509:3
npm错误!Windows\u NT 10.0.14393
npm ERR!argv“C:\\Program Files\\nodejs\\node.exe”“C:\\Users\\Eduardo\\AppData\\Roaming\\npm\\node\u modules\\npm\\bin\\npm cli.js”“运行”“测试”
npm错误!节点v6.10.0
npm错误!npm v4.3.0
npm错误!代码错误周期
npm错误!错误1
npm ERR!btc watcher@test:`node--debug=5858 test.js`
npm错误!退出状态1
npm错误!
npm ERR!在btc watcher@test script“节点--debug=5858 test.js”失败。
npm错误!请确保已安装最新版本的node.js和npm。
npm ERR!如果您这样做,这很可能是btc watcher包的问题,
npm错误!与npm本身无关。
npm ERR!告诉作者此操作在您的系统上失败:
npm ERR!node--debug=5858 test.js
npm ERR!您可以通过以下方式获取有关如何打开此项目问题的信息:
npm错误!npm错误btc观察者
npm ERR!如果不可用,您可以通过以下方式获取他们的信息:
npm错误!npm所有者ls btc观察者
npm ERR!上面可能还有其他日志输出。
npm ERR!请在任何支持请求中包含以下文件:
npm ERR!C:\Users\Eduardo\AppData\Roaming\npm cache\\u logs\2017-03-04T01\u 36\u 28\u 318Z-debug.log

请帮助!

您不是通常使用casperjs命令运行casperjs脚本吗?例如casperjs test.js否,我生成一个NodeJS应用程序,并使用
node test.js运行此代码