本文介绍了有没有办法制作“npm ci"?安装 devDependencies,或“npm install"不更新 package-lock.json?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为新开发人员在他们的本地开发环境中安装我们的代码库整理文档.我想给他们以下命令:

I'm trying to put together documentation for new developers installing our codebase on their local development environments. I'd like to give them command(s) that:

  • 根据 package-lock.json 中的版本安装 devDependencies 和依赖项
  • 不更新 package-lock.json

"npm ci" 几乎完全符合我的要求,但似乎没有安装 devDependencies.npm install"确实会安装 devDependencies,但它有时会修改 package-lock.json.

"npm ci" does almost exactly what I want, but doesn't seem to install devDependencies. "npm install" does install devDependencies, but it sometimes modifies package-lock.json.

我可以想象像npm install && git checkout package-lock.json"之类的东西,但我觉得必须有一种更惯用的方式说给我一个干净安装这个项目的开发依赖项?"

I could imagine something janky like "npm install && git checkout package-lock.json", but I feel like there must be a more idiomatic way of saying "give me a clean install of this project's dependencies for development?"

推荐答案

npm ci 确实安装了依赖项和开发依赖项.但是如果你使用 npm ci --production 或者如果你的 NODE_ENV 设置为生产,那么它避免安装开发依赖项.请在此处查看文档.

npm ci does install both dependecies and dev dependencies. But if you use npm ci --production or if your NODE_ENV is set to production, then it avoids installing dev dependencies.Please check docs here.

使用 --production 标志(或当 NODE_ENV 环境变量设置为生产),npm 将不会安装中列出的模块开发依赖项.

注意:--production 标志在添加对项目的依赖.

NOTE: The --production flag has no particular meaning when adding a dependency to a project.

这篇关于有没有办法制作“npm ci"?安装 devDependencies,或“npm install"不更新 package-lock.json?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 00:44