[英]Syntax for including node.js modules in .js files?
使用npm,我抓起了这个包。 https://npmjs.org/package/phantom-crawl
我该如何运行? - 示例脚本给了我这个错误:
错误:找不到模块“ ./src/PhantomCrawl”
phantomjs://bootstrap.js:289
phantomjs://bootstrap.js:254 in require
example.js:3
具体来说,该行需要更改; 但是不确定为此使用的nodejs路径语法:
var PhantomCrawl = require('./src/PhantomCrawl');
您需要相对于src
目录运行它。 因此,如果您使用npm install phantom-crawl
在本地npm install phantom-crawl
您需要先运行cd node_modules/phantom-crawl
然后才能运行该示例。 这也恰好在该目录中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.