- npm ci 要求必需有
package-lock.json
或npm-shrinkwrap.json
文件存在 - 如果 lock 與
package.json
中版本不匹配, npm ci 直接報錯中斷,而不是更新 lock 文件 - npm ci 不能用來安裝單個依賴,只能用來安裝整個項目的依賴
- npm ci 會檢測如果
node_modules
已經存在,則先刪除再進行安裝操作 - npm ci 會安裝
dependencies
和devDependencies,
- 和 npm install 一樣,生產環境下,即通過
-—production
或通過NODE_ENV
配置,則只會安裝 dependencies
- 和 npm install 一樣,生產環境下,即通過
- 不會更新
package.json
或package-lock.json
文件,整個安裝過程是鎖死的 - 緩存
npm ci --cache .npm
- npm ci 時建議加上
--quiet --no-progress
關閉進度和其他無用 log,否則產生的日志會很大。 - 所以 ci 時推薦完整的命令為
npm ci --cache .npm --quiet --no-progress
相關資源
- npm-ci
- What is the difference between “npm install” and “npm ci”?
- Is there a way to speedup npm ci using cache?
The text was updated successfully, but these errors were encountered: