2011-10-24 93 views
3

我正在部署一個node.js應用程序deps /模塊,如:stylus,express,socket.io在heroku上。Heroku說:找不到模塊'socket.io'

的server.js

/** 
* Bootstrap app. 
*/ 

// I've tried with and without that line... not sure what it does 
require.paths.unshift(__dirname + '/../../lib/'); 



/** 
* Module dependencies. 
*/ 

// I've tried with "socket.io", "./socket.io" and "Socket.IO" 
var express = require('express') 
    , stylus = require('stylus') 
    , nib = require('nib') 
    , sio = require('socket.io'); 

文件的package.json

{ 「名」 的開頭: 「test.io」, 「說明」: 「布拉布拉」,「版本「:」0.0.1「,」依賴關係「:{ 」express「:」2.3.11「 ,」jade「:」0.12.1「 ,」手寫筆「:」0.13.3「 」筆尖「:」0.0.8「 }}

因此,唯一的一個heroku web工作者崩潰。這裏的日誌:

2011-10-24T09:15:27+00:00 heroku[slugc]: Slug compilation finished 
2011-10-24T09:15:35+00:00 heroku[web.1]: Unidling 
2011-10-24T09:15:35+00:00 heroku[web.1]: State changed from down to created 
2011-10-24T09:15:35+00:00 heroku[web.1]: State changed from created to starting 
2011-10-24T09:15:39+00:00 heroku[web.1]: State changed from starting to crashed 
2011-10-24T09:15:39+00:00 heroku[web.1]: State changed from crashed to created 
2011-10-24T09:15:39+00:00 heroku[web.1]: State changed from created to starting 
2011-10-24T09:15:41+00:00 heroku[web.1]: Starting process with command `node app.js` 
2011-10-24T09:15:41+00:00 app[web.1]: 
2011-10-24T09:15:41+00:00 app[web.1]: node.js:134 
2011-10-24T09:15:41+00:00 app[web.1]:   throw e; // process.nextTick error, or 'error' event on first tick 
2011-10-24T09:15:41+00:00 app[web.1]:  ^
2011-10-24T09:15:41+00:00 app[web.1]: Error: Cannot find module 'socket.io' 
2011-10-24T09:15:41+00:00 app[web.1]:  at Function._resolveFilename (module.js:320:11) 
2011-10-24T09:15:41+00:00 app[web.1]:  at Function._load (module.js:266:25) 
2011-10-24T09:15:41+00:00 app[web.1]:  at require (module.js:348:19) 
2011-10-24T09:15:41+00:00 app[web.1]:  at Object.<anonymous> (/app/app.js:18:11) 
2011-10-24T09:15:41+00:00 app[web.1]:  at Module._compile (module.js:404:26) 
2011-10-24T09:15:41+00:00 app[web.1]:  at Object..js (module.js:410:10) 
2011-10-24T09:15:41+00:00 app[web.1]:  at Module.load (module.js:336:31) 
2011-10-24T09:15:41+00:00 app[web.1]:  at Function._load (module.js:297:12) 
2011-10-24T09:15:41+00:00 app[web.1]:  at Array.<anonymous> (module.js:423:10) 
2011-10-24T09:15:41+00:00 app[web.1]:  at EventEmitter._tickCallback (node.js:126:26) 
2011-10-24T09:15:41+00:00 heroku[web.1]: Process exited 
2011-10-24T09:15:44+00:00 heroku[web.1]: State changed from starting to crashed 

那麼,有什麼想法?有沒有發生過任何人?

回答

0

你確定你已經安裝了socket io嗎?嘗試運行:

npm install socket.io 

這將在節點數據包存儲庫中安裝最新的socket.io。

+0

這是在heroku上。我可以在其上運行npm嗎? Gonnar嘗試... –

8

我相信你應該在package.json中的依賴關係中添加socket.io。

{ "name": "test.io" , "description": "blabla" , "version": "0.0.1" , "dependencies": { "express": "2.3.11" , "jade": "0.12.1" , "stylus": "0.13.3" , "nib": "0.0.8" , "socket.io" : "0.8.5" } } 

或者只是這樣做:

npm install socket.io --save

這將安裝最新版本的socket.io,並把它添加到依賴關係。

3
npm install socket.io 

爲我做了詭計。如果您在Windows下,請確保您以管理員身份運行它。

相關問題