I have a bunch of devDependencies
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 devDependencies
, 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?
There is no noticable difference between --save and --save-dev when developing. To take the moment. js example: when running webpack, the moment code is taken from node_modules and included in the project. In this sense there is no difference with typescript which is also needed when running webpack.
To skip Installation of devDepenencies pass --production flag to npm install ,with the --production flag(or NODE_ENV environment variable set to production ) npm will not install modules listed in devDependencies." To make any module to be part of devDependencies pass --dev while installing.
To add dependencies and devDependencies to a package. json file from the command line, you can install them in the root directory of your package using the --save-prod flag for dependencies (the default behavior of npm install ) or the --save-dev flag for devDependencies.
By default, npm install will install all modules listed as dependencies in package. json . With the --production flag (or when the NODE_ENV environment variable is set to production ), npm will not install modules listed in devDependencies .
September, 2016:
As others have mentioned as well, there were some huge efforts to enhance the shrinkwrap feature starting with npm v3.10.8.
Thanks to this, it'll be possible to keep your devDependencies
locked while installing only the production dependencies:
npm shrinkwrap --dev npm install --only=prod
2013 answer:
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 installeddevDependencies
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.
It looks like this feature was recently added in v3.3 of the npm client per the changelog
You'll now be able to run npm install --only=prod
to achieve the effect you wish.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With