Jesse Fulton
Jesse Fulton

Reputation: 2218

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?

Upvotes: 8

Views: 9142

Answers (3)

Roy Truelove
Roy Truelove

Reputation: 22456

There's a tool called penv that looks promising. From their site:

Sometimes we need a different package.json properties for our different environments like production, staging and development. (Ex: jitsu deploys)

With penv you can customize your package.json file with properties defined inside an environments.json file.

Actually going to try it out now.

Upvotes: 4

kevin
kevin

Reputation: 1572

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

Upvotes: 4

Neil Middleton
Neil Middleton

Reputation: 22238

Maybe you could use a Heroku specific branch in Git and merge into that prior to deploy (ensuring that you don't merge over your package.json).

Upvotes: 1

Related Questions