2013-07-23 41 views
0

使用npm,我抓住了这个包。 https://npmjs.org/package/phantom-crawl在.js文件中包含node.js模块的语法?

我该如何运行它? - 该example script给了我这个错误:

Error: Cannot find module './src/PhantomCrawl'

phantomjs://bootstrap.js:289 
phantomjs://bootstrap.js:254 in require 
example.js:3 

特别需要这条线改变;但不确定的路径的NodeJS语法用于此:

var PhantomCrawl = require('./src/PhantomCrawl'); 
+0

奇怪的是,它为我工作。你使用什么Node版本?我在0.10.13。 – gustavohenke

+0

我也在0.10.13。我敢肯定,'git克隆'它会工作;然而,我试图弄清楚如何从'npm install phantom-crawl'中执行它...... – stackoverflowuser95

回答

0

你需要它相对于src目录中运行。 因此,如果您使用npm install phantom-crawl在本地安装,则在运行该示例之前,您需要使用cd node_modules/phantom-crawl。这也恰好在该目录中。

+0

等等,所以'npm install'没有比'git clone'更有用吗? - 所以我应该设置一个环境变量到'node_modules'并从那里开始工作? :/ – stackoverflowuser95

+0

那么没有.. npm安装依赖关系等。但是这个例子特别需要src目录中的文件。从你的项目你应该能够使用require(“幻影爬行”) –