2013-07-23 43 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(「幻影爬行」) –