3

I have a Node.js app with npm-shrinkwrap.json checked in. When I run npm install locally, it installs the versions specified in npm-shrinkwrap.json, but when I push it to Heroku (on the Cedar stack), it seems to ignore the shrinkwrap and simply installs the newest version.

Am I doing something wrong? I don't need to to check in node_modules, do I?

2 Answers 2

5

As you say in your answer, when Heroku wrote the Nodejs buildpack, the feature npm shrinkwrap didn't exist.

However, as of version 1.1.2, npm install tries npm-shrinkwrap.json first, falling back to package.json. This means that Heroku respects it (even though the feature hadn't been conceived when Heroku wrote their code). Isaacs is awesome.

So just add to your package.json:

"engines": {
  "node": "0.8.x",
  "npm": ">=1.1.2"
}

Then run npm shrinkwrap, and git add npm-shrinkwrap.json. Then commit as normal.

2

As it turns out, Heroku uses npm 1.0.106 at the moment, but shrinkwrap was only added in npm 1.1.2, according to the changelog.

Adding node_modules has solved my problem, until Heroku upgrade their npm.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.