Npm i and npm ci , what difference?
Npm i and npm ci , what difference?
npm install / npm i - installation which can rewrite package.json and package-lock.json
npm ci - clean install which removes node_modules and use package-lock json for installing and do not rewrite them package-lock.json and package.json
npm install
- Installs a package and all its dependencies.
- Dependencies are driven by
npm-shrinkwrap.jsonandpackage-lock.json(in that order). - without arguments: installs dependencies of a local module.
- Can install global packages.
- Will install any missing dependencies in
node_modules. - It may write to
package.jsonorpackage-lock.json.- When used with an argument (
npm i packagename) it may write topackage.jsonto add or update the dependency. - when used without arguments, (
npm i) it may write topackage-lock.jsonto lock down the version of some dependencies if they are not already in this file.
- When used with an argument (
npm ci
- Requires at least npm v5.7.1.
- Requires
package-lock.jsonornpm-shrinkwrap.jsonto be present. - Throws an error if dependencies from these two files don't match
package.json. - Removes
node_modulesand install all dependencies at once. - It never writes to
package.jsonorpackage-lock.json.
Comments