0

我认为这是我使用的 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问题?

4

1 回答 1

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"
  }
}
于 2012-08-12T19:31:18.840 回答