2013-02-11 89 views
2

即時通訊新手,我安裝了nodejs與安裝程序在Windows中。 然後我用這個命令安裝了WebSocket-Node模塊: npm install websocket,看起來像成功安裝。nodejs module.js:340 throw err;使用WebSocket節點

c:\Program Files (x86)\nodejs\

現在我嘗試從https://github.com/Worlize/WebSocket-Node 即時得到這個錯誤執行server.js例如:

D:\dev\html5\books\bumper>node server.js 

module.js:340 
    throw err; 
     ^
Error: Cannot find module '/path/to/websocket' 
    at Function.Module._resolveFilename (module.js:338:15) 
    at Function.Module._load (module.js:280:25) 
    at Module.require (module.js:362:17) 
    at require (module.js:378:17) 
    at Object.<anonymous> (D:\dev\html5\books\bumper\server.js:3:23) 
    at Module._compile (module.js:449:26) 
    at Object.Module._extensions..js (module.js:467:10) 
    at Module.load (module.js:356:32) 
    at Function.Module._load (module.js:312:12) 
    at Module.runMain (module.js:492:10) 

也模塊

npm http GET https://registry.npmjs.org/websocket 
npm http 200 https://registry.npmjs.org/websocket 
npm http GET https://registry.npmjs.org/websocket/-/websocket-1.0.8.tgz 
npm http 200 https://registry.npmjs.org/websocket/-/websocket-1.0.8.tgz 

> [email protected] install D:\dev\html5\books\bumper\node_modules\websocket 
> node install.js 

[websocket v1.0.8] Attempting to compile native extensions. 
[websocket v1.0.8] Native extension compilation successful! 
[email protected] node_modules\websocket 

它在這個位置安裝的NodeJS安裝在項目根目錄下沒有在nodejs目錄中,可以嗎?

回答

1

基於它看起來像需要對線路錯誤消息看起來像這樣

var websocket = require('/path/to/websocket'); 

一旦你安裝了故宮的東西,你可以只使用模塊名稱:

var websocket = require('websocket'); 
相關問題