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

前端 未结 5 1697
爱一瞬间的悲伤
爱一瞬间的悲伤 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:34

    As to npm 5 (I've tried on 5.5.1 and 5.6.0), --production (--only=prod) flag is problematic.

    When package-lock.json exists in the folder,

    npm shrinkwrap --production
    

    simply changes the file name to npm-shrinkwrap.json.

    How I managed to solve this issue is to run:

    npm prune --production
    

    and then run:

    npm shrinkwrap --production
    

提交回复
热议问题