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

前端 未结 5 1694
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-23 14:11

I have a bunch of devDependencies needed in order to run test suite and have production dependencies locked down with npm shrinkwrap. The problem i

5条回答
  •  佛祖请我去吃肉
    2020-12-23 14:25

    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 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.

提交回复
热议问题