Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Heroku 'cannot find module zlib' in NodeJS

Heroku 'cannot find module zlib' in NodeJS

Problem

I think this is an issue with which version of NodeJS I'm using, but I'm having trouble finding the actual issue and resolution. Here is the heroku log:

 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.
 (/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.
 (/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)

And here is my package.json:

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

I have node v0.6.13 on my local machine and am using that. Should I declare a node version in my package.json? Which version alleviates this zlib issue?

Problem courtesy of: Miles

Solution

I don't know what the default version of node is on Heroku, but I think it's broken. I forced Heroku to use the version of Node.js I'm using and it worked:

{
    "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"
  }
}
Solution courtesy of: Miles

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Heroku 'cannot find module zlib' in NodeJS

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×