yarn中最接近`npm ci`的是什么
What is the closest to `npm ci` in yarn
在 npm 中,有一个 ci
命令用于以干净状态安装项目。在文档中,it is claimed 即:
It can be significantly faster than a regular npm install by skipping
certain user-oriented features. It is also more strict than a regular
install, which can help catch errors or inconsistencies caused by the
incrementally-installed local environments of most npm users.
纱线世界中最接近 npm ci
命令的等价物是什么?也许答案是我们不需要在 yarn 中使用它,因为它的架构使我们不需要特殊模式。也许答案是使用一堆配置设置。但是,我没能找到这个问题的完整答案,我相信拥有它会很有价值。
我相信就这么简单:
yarn install --frozen-lockfile
不幸的是,由于 yarn 模块解析的工作方式,仅执行 yarn install --frozen-lockfile
有时是不够的。您仍然可以留下无效的传递依赖。
要真正获得与 npm ci
相同的行为,您必须这样做:
rm -rf node_modules && yarn install --frozen-lockfile
根据@Crafty_Shadow 的建议,我使它更加集成。
package.json
...
"scripts": {
...
"preci": "rm -fr node_modules",
"ci": "yarn install --frozen-lockfile"
},
...
对于较新版本的纱线,您应该使用:
yarn install --immutable --immutable-cache --check-cache
If the --check-cache
option is set [...] This is recommended as part of your CI workflow if you're both following the Zero-Installs model and accepting PRs from third-parties, as they'd otherwise have the ability to alter the checked-in packages before submitting them.
在 npm 中,有一个 ci
命令用于以干净状态安装项目。在文档中,it is claimed 即:
It can be significantly faster than a regular npm install by skipping certain user-oriented features. It is also more strict than a regular install, which can help catch errors or inconsistencies caused by the incrementally-installed local environments of most npm users.
纱线世界中最接近 npm ci
命令的等价物是什么?也许答案是我们不需要在 yarn 中使用它,因为它的架构使我们不需要特殊模式。也许答案是使用一堆配置设置。但是,我没能找到这个问题的完整答案,我相信拥有它会很有价值。
我相信就这么简单:
yarn install --frozen-lockfile
不幸的是,由于 yarn 模块解析的工作方式,仅执行 yarn install --frozen-lockfile
有时是不够的。您仍然可以留下无效的传递依赖。
要真正获得与 npm ci
相同的行为,您必须这样做:
rm -rf node_modules && yarn install --frozen-lockfile
根据@Crafty_Shadow 的建议,我使它更加集成。
package.json
...
"scripts": {
...
"preci": "rm -fr node_modules",
"ci": "yarn install --frozen-lockfile"
},
...
对于较新版本的纱线,您应该使用:
yarn install --immutable --immutable-cache --check-cache
If the
--check-cache
option is set [...] This is recommended as part of your CI workflow if you're both following the Zero-Installs model and accepting PRs from third-parties, as they'd otherwise have the ability to alter the checked-in packages before submitting them.