Linux command
npm-ci 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Clean install from lockfile
npm ci
Install production only
npm ci --production
Install with legacy peer deps
npm ci --legacy-peer-deps
Silent install
npm ci --silent
说明
npm ci performs a clean install of dependencies based exactly on the package-lock.json file. It is designed for automated environments like CI/CD pipelines where reproducibility is critical. The command deletes any existing node_modules directory before installing, ensuring a clean state. Unlike npm install, it never modifies the lockfile — if package.json and package-lock.json are out of sync, it fails with an error rather than silently updating.
参数
- --production
- Skip devDependencies (npm 6; use --omit=dev in npm 7+).
- --omit _TYPE_
- Omit dependency type (dev, optional, peer).
- --legacy-peer-deps
- Ignore peer dep conflicts.
- --silent
- Suppress output.
- --help
- Display help information.
FAQ
What is the npm-ci command used for?
npm ci performs a clean install of dependencies based exactly on the package-lock.json file. It is designed for automated environments like CI/CD pipelines where reproducibility is critical. The command deletes any existing node_modules directory before installing, ensuring a clean state. Unlike npm install, it never modifies the lockfile — if package.json and package-lock.json are out of sync, it fails with an error rather than silently updating.
How do I run a basic npm-ci example?
Run `npm ci` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --production do in npm-ci?
Skip devDependencies (npm 6; use --omit=dev in npm 7+).