npm ci
安装一个干净的项目
概要
npm ci
描述
此命令与 npm install
类似,不同之处在于它旨在用于自动化环境,例如测试平台、持续集成和部署——或任何您希望确保对依赖项进行全新安装的情况。
npm ci
在以下情况下会明显更快:
- 有一个
package-lock.json
或npm-shrinkwrap.json
文件。 node_modules
文件夹丢失或为空。
简而言之,使用 npm install
和 npm ci
的主要区别在于:
- SUc2ndgoJ9NhsUmlQ0lSjaq4q3vhdMBGZ0b9qFHyVY5zJHpDgV4vxfh+86ywT96cB/jGxHnwGD72FbqkQ4rvq6uCvM5I8HaU1qBQ60OcTIqwqPvHENbE507szAEZsJQWxhNvYKdKxiJb9OGaRbzGrJA9FCHCtI+6ty9HMjTMnax7WStgCJ38CivOlidA12aaaCH1nxYTRsXKAFU0I+Yo2x7mO2UNLKOLbycINFUkHCq+g3ef392jb0Cn7skHjmWuNrW0qccOaUSss68JgAjyIMrpbNRmkUcYcEUwGTlSbJdkKgJ8TJzxHlEXpSiI9WI4+sOreb917HizPpxbolh77YXKnMvHmQm4xoM6etTlLx5JNPmnWvSWhLDtKAgkgjTSO0jl5+QQGLeYzFFSpy8LOmwuLAejPJWrzgSIdRrYHZVodXU5eIH81G+hOL96BfUYL1skMZGmPccjsDIGOqJ5Kh04c3ChyuRlgUgDFRPQLZadrW57kB5jeSRU5GeOeHg/4PuRLFfkcXxWECwAJw/eK+cH5NUf8eFuZcvj8cTzb81fBHJAv7UZ89WhEmzvxdv9eF3RDFTBmBN/32f8WWIo9Yt1rfbFSf0FLiYudyC5iChbJvSV2U3sCVCszGxNjmuBc139fs2Vac/OtS7jlxDcr+KUKqiL0cpyryAg2neuoAlcwJHIpe6O1jvQnGlWn/tSZ85X6KGgW7vda0+RAUaJijUeE3nWaYWpIFfEtOqavjNBlwpm8R9shQ5+Z+7vYs614Vg7lWj2C9vFpCuysSXiIk8fws97+8EUJU4749qqIok=
示例
wCAX7hFEULMlpFFXcrzOGRfDNXXR25/m8ZzFuM2YN6uWiUGo4KQBS29R9V2Y4vKYAmFB6yaBtlHwgWTH1uZFSQ==
$ cd ./my/npm/project
$ npm install
added 154 packages in 10s
$ ls | grep package-lock
JGXI19bkRCkDbvUGC6LUvdvAG9HOndug9fpRC+k/0mF+eVbYysnsWAneoD308uSF
$ npm ci
added 154 packages in 5s
3jKrTYQzP6ccg3jH6yt3KXrG6dIwdhX/5NEXpqoWGdD8snaQ9Sb+I6xuaxg2zZ09b49qLsG77Vn5X2bstimwhYCN3KGgenDUgBxByUH6nrfQ4MFpCUB4wAxdtRnEStTX
# .travis.yml
install:
- npm ci
# keep the npm cache around to speed up installs
cache:
directories:
- "$HOME/.npm"
配置
audit
- EpH0pOUcYTmP1NTiHWcSlvc59cMRladRHoLV5jMq9t4AJJy5eeCQOazNRGakPPY4f8SDsLYQzvz2yC6gG4f0JA==
bc2amoQfOOVQ8ljsAa5MhlBUy8+5VSxcXvrp6rBfT/6udUcQXchKmOX4kX4xAKStReghkXwVFJZ+2AgmHQ/GEKj+6oA2AbcGF8CVP7aThpjJ9pX3zkzoTibVjumfh3qA9aYFJAgML7A0ZEufeD1XuanNxecxAP5tngw7Bqs7mjRO7z2wZSbPv8JFCHfiFyTeVTd9JxLqAoC8dRqSDWQdYNMYCXtqhNuJxVVbm3xIt46A5Bhm2M5JNKTO5IeXr2Spp2j8mPnpdlQyIU0r5XO4t4X7Cs1CcWUqsC8kILolaNoQRQHOiepcKDhmpzP54th7m8mXZ9L2aAUplqzYqXYCnQ==
ignore-scripts
- EpH0pOUcYTmP1NTiHWcSliUJTBm//oVXh/pDP8UGh5dbSujBiD6FY3AqOvsSLxA8vKUZeAW9UrwwVzFqUQF35A==
KtGQswljOfrysKoM9lTZxKEUK+thIYsYF565ukHx4M2JMwfeJBI9eAXJLoI710Q8Tz1dM70rrZkshURIzWJGDx3ZwpTsyfonx8P0oT7pPHI=
dIl01/wrWmPY6FA2Rw0n/nyJ5uPPbByXRxiyqcurcZ1JMURukNVO9ravKunISGb7+2G9NzMI2Mm596Uguv++YfRAeQrb5c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