Heroku'在NodeJS中找不到模块zlib'

时间:2012-08-11 19:35:03

标签: node.js heroku express

我认为这是我正在使用哪个版本的NodeJS的问题,但是我无法找到实际的问题和解决方案。这是heroku日志:

 2012-08-11T19:25:48+00:00 heroku[web.1]: Starting process with command
 `node app.js` 2012-08-11T19:25:49+00:00 app[web.1]: 
 2012-08-11T19:25:49+00:00 app[web.1]: node.js:134
 2012-08-11T19:25:49+00:00 app[web.1]:         throw e; //
 process.nextTick error, or 'error' event on first tick
 2012-08-11T19:25:49+00:00 app[web.1]: Error: Cannot find module 'zlib'
 2012-08-11T19:25:49+00:00 app[web.1]:         ^
 2012-08-11T19:25:49+00:00 app[web.1]:     at Function._load
 (module.js:266:25) 2012-08-11T19:25:49+00:00 app[web.1]:     at
 Function._resolveFilename (module.js:320:11) 2012-08-11T19:25:49+00:00
 app[web.1]:     at require (module.js:348:19)
 2012-08-11T19:25:49+00:00 app[web.1]:     at Object.<anonymous>
 (/app/node_modules/express/node_modules/connect/lib/middleware/compress.js:14:12)
 2012-08-11T19:25:49+00:00 app[web.1]:     at Module._compile
 (module.js:404:26) 2012-08-11T19:25:49+00:00 app[web.1]:     at
 Module.load (module.js:336:31) 2012-08-11T19:25:49+00:00 app[web.1]:  
 at Object..js (module.js:410:10) 2012-08-11T19:25:49+00:00 app[web.1]:
 at require (module.js:348:19) 2012-08-11T19:25:49+00:00 app[web.1]:   
 at Object.compress
 (/app/node_modules/express/node_modules/connect/lib/connect.js:89:14)
 2012-08-11T19:25:49+00:00 app[web.1]:     at Function._load
 (module.js:297:12) 2012-08-11T19:25:50+00:00 heroku[web.1]: Process
 exited with status 1 2012-08-11T19:25:50+00:00 heroku[web.1]: State
 changed from starting to crashed 2012-08-11T19:25:50+00:00
 heroku[web.1]: State changed from crashed to starting
 2012-08-11T19:25:52+00:00 heroku[web.1]: Starting process with command
 `node app.js` 2012-08-11T19:25:53+00:00 app[web.1]: 
 2012-08-11T19:25:53+00:00 app[web.1]: node.js:134
 2012-08-11T19:25:53+00:00 app[web.1]:         throw e; //
 process.nextTick error, or 'error' event on first tick
 2012-08-11T19:25:53+00:00 app[web.1]:         ^
 2012-08-11T19:25:53+00:00 app[web.1]: Error: Cannot find module 'zlib'
 2012-08-11T19:25:53+00:00 app[web.1]:     at Function._resolveFilename
 (module.js:320:11) 2012-08-11T19:25:53+00:00 app[web.1]:     at
 Function._load (module.js:266:25) 2012-08-11T19:25:53+00:00
 app[web.1]:     at require (module.js:348:19)
 2012-08-11T19:25:53+00:00 app[web.1]:     at Object.<anonymous>
 (/app/node_modules/express/node_modules/connect/lib/middleware/compress.js:14:12)
 2012-08-11T19:25:53+00:00 app[web.1]:     at Module._compile
 (module.js:404:26) 2012-08-11T19:25:53+00:00 app[web.1]:     at
 Object..js (module.js:410:10) 2012-08-11T19:25:53+00:00 app[web.1]:   
 at Module.load (module.js:336:31) 2012-08-11T19:25:53+00:00
 app[web.1]:     at Function._load (module.js:297:12)
 2012-08-11T19:25:53+00:00 app[web.1]:     at require
 (module.js:348:19) 2012-08-11T19:25:53+00:00 app[web.1]:     at
 Object.compress
 (/app/node_modules/express/node_modules/connect/lib/connect.js:89:14)

这是我的package.json

{
     "name": "App"   , "version": "0.0.1"   , "private": true   , "dependencies": {
       "express": "2.5.8"
     , "jade": ">= 0.0.1"   } 
}

我的本​​地计算机上有节点v0.6.13并且正在使用它。我应该在package.json中声明节点版本吗?哪个版本可以缓解此zlib问题?

1 个答案:

答案 0 :(得分:5)

我不知道Heroku上的节点的默认版本是什么,但我认为它已经坏了。我强迫Heroku使用我正在使用的Node.js版本并且它有效:

{
    "name": "FriendButler"
  , "version": "0.0.1"
  , "private": true
  , "dependencies": {
      "express": "2.5.8"
    , "jade": ">= 0.0.1"
  }
  , "engines": {
      "node": "0.6.13",
      "npm": "1.1.41"
  }
}