Fluffy Fluffy - 1 year ago 127
Node.js Question

How to shrinkwrap devDependencies, but not install them unless necessary?

I have a bunch of

needed in order to run test suite and have production dependencies locked down with
npm shrinkwrap
. The problem is that when I run
npm install
, only production dependencies are installed, in order to install
, I have to remove npm-shrinkwrap.json and run it again. Now if shrinkwrap contains devDependencies as well, they get installed in production, where they are not required. Surely there should be some command line arguments to force only normal dependencies to be installed?

Answer Source

As stated in the NPM docs:

Since npm shrinkwrap is intended to lock down your dependencies for production use, devDependencies will not be included unless you explicitly set the --dev flag when you run npm shrinkwrap. If installed devDependencies are excluded, then npm will print a warning. If you want them to be installed with your module by default, please consider adding them to dependencies instead.

Basically, or you lock down all deps, or only the production deps.

Not even running npm install --dev or npm install --force can transcend the shrinkwrap functionality.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download