以下差异涵盖了npm i和npm ci命令的不同之处及其功能。这被称为其用于管理需要为我们的应用模块的节点包管理器故宫。
npm i: npm i(或 npm install)用于从package.json文件安装所有依赖项或 devDependencies。
句法:
npm install "package-name"
// OR
npm i "package-name"
npm ci: CI 代表持续集成,npm ci 用于从 package-lock.json 文件安装所有确切的版本依赖项或 devDependencies。
句法:
npm ci
npm i和npm ci之间的区别是:
S.No. |
npm i |
npm ci |
1. | It installs a package and all its dependencies. | It is generally used to install dependencies. |
2. | It may write to package.json or package-lock.json. | It never writes to package.json or package-lock.json. |
3. | Individual dependencies can be added with this command. | Individual dependencies cannot be added with this command. |
4. | It is slower in execution. | It is faster in execution. |
5. | If any dependency is not in package-lock.json, This command will add it. | If any dependencies are missing or have incompatible versions, then npm ci will throw an error. |
6. | If a node_modules is already present, This Command doesn’t change anything to it. | If a node_modules is already present, it will be automatically removed before npm ci begins its install. |
7. | It can install global packages. | It can not install global packages. |
8. | The npm i package-name is used to right to package.json to add or update dependencies. | It can’t be used to write to package.json. |
9. | npm i may right to package-lock.json to lock version of some dependencies. | It can’t write to package-lock.json. |
10 . | Used during development after pulling changes that update the list of dependencies. | Used for the deterministic, repeatable build. |