Jesse Fulton Jesse Fulton - 2 months ago 25
Node.js Question

package.json for different environments?

I have a node.js app which I've just deployed to Heroku which depends upon the canvas module. However, that module requires the cairo graphics library and long story short, I need to use a precomipiled version which is included with this fork of canvas.

Normally, my package.json dependencies look like:

"dependencies" : {
"canvas" : "0.10.0",
"express" : "2.5.6",
"jade" : "0.20.1"
}


But in order to get my app to work on Heroku, I must pull in the fork from github

"dependencies" : {
"canvas" : "git://github.com/elspoono/node-canvas-heroku.git#master",
"express" : "2.5.6",
"jade" : "0.20.1"
}


Is it possible to have a "Heroku-only" version of package.json? Or is there another section in package.json where I can "override" the canvas dependency in dev environments?

Answer

Never used Heroku but package.json format defines the devDependencies field, see Nodejitsu cheatsheet. Then install with $ npm install -d.