What is the difference between “npm install” and “npm ci”?

后端 未结 6 1143
北荒
北荒 2020-11-30 16:42

I\'m working with continuous integration and discovered the npm ci command.

I can\'t figure what the advantages are of using this command for my workflow.

6条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 17:24

    The commands are very similar in functionality however the difference is in the approach taken to install the dependencies specified in your package.json and package-lock.json files.

    npm ci performs a clean install of all the dependencies of your app whereas npm install may skip some installations if they already exist on the system. A problem may arise if the version already installed on the system isn't the one your package.json intended to install i.e. the installed version is different from the 'required' version.

    Other differences would be that npm ci never touches your package*.json files. It will stop installation and show an error if the dependency versions do not match in the package.json and package-lock.json files.

    You can read a much better explanation from the official docs here.

    Additionally, you may want to read about package locks here.

提交回复
热议问题