我需要一堆 devDependencies
来运行测试套件并使用 npm shrinkwrap
锁定生产依赖项。问题是当我运行 npm install
时,只安装了生产依赖项,为了安装 devDependencies
,我必须删除 npm-shrinkwrap.json 并再次运行它。
现在,如果 shrinkwrap 也包含 devDependencies
,它们会安装在生产环境中,而不需要它们。当然应该有一些命令行参数来强制只安装正常的依赖项?
最佳答案
2016 年 9 月:
正如其他人也提到的那样,从 npm v3.10.8 开始,我们付出了巨大的努力来增强收缩包装功能。 .
感谢 this ,您可以在仅安装生产依赖项时保持 devDependencies
锁定:
npm shrinkwrap --dev
npm install --only=prod
2013 年回答:
如 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.
基本上,或者你锁定所有部门,或者只锁定生产部门。
即使运行 npm install --dev
或 npm install --force
也无法超越收缩包装功能。
关于node.js - 如何收缩包装 devDependencies,但除非必要,否则不要安装它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17544051/