【发布时间】:2018-01-26 13:48:52
【问题描述】:
我目前正在尝试让 Casperjs 在我的 Nodejs discord 机器人上工作。但是每次我想测试它(使用 casperjs 文档提供的示例)
var casper = require("casper").create();
casper.start('http://casperjs.org/', function() {
this.echo(this.getTitle());
});
casper.thenOpen('http://phantomjs.org', function() {
this.echo(this.getTitle());
});
casper.run();
每当我想开始真正的编码时,我都会遇到“找不到模块 casper”。我该如何解决这个问题?
我已经尝试了一些来自 stackoverflow 的解决方案,但似乎都已经过时了/我用错了。
我还读到我需要用于 casper 的 phantomjs(所以我做了 npm install phantom),但不知道我是否需要用它做更多的事情。后来我还读到 casper 现在可以单独使用了。我按照 casper.js 网站上的快速入门指南进行操作,但没有成功。
感谢您的回答!
【问题讨论】:
-
npm install casper? -
是的,我做到了,并且可以在我的 node-modules 文件夹中找到 casperjs
-
我的错,包名是
casperjs,而不是casper。你应该这样做npm install casperjs -
如何运行示例脚本?
-
我用 npm run test 运行它,它会启动我的 main.js
标签: node.js installation phantomjs casperjs