Raivo Laanemets. Software consultant.

npm shrinkwrap and a new dependency


The npm shrinkwrap command locks down versions of the installed dependencies. However, you must rerun the shrinkwrap command every time you add new dependencies into your package.json file using the npm install <package> --save command. Failure to do so will result in a runtime error stating that you have a module missing:

Error: Cannot find module 'xxx'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    ...

You get no install-time error when package.json and npm-shrinkwrap.json are inconsistent (dependency X missing from shrinkwrap) and the npm install command is run (X is not installed). Because of this you must always do the following:

npm install <package> --save
npm shrinkwrap

This behavior might change in newer versions of npm. Relevant issues:


Comments

No comments have been added so far.

Email is not displayed anywhere.
URLs (max 3) starting with http:// or https:// can be used. Use @Name to mention someone.