2017-08-10 36 views
0

在一个项目中,我用纱代替了npm,以获得它的好处,并且强制我们的依赖关系通过yarn.lock被锁定。当package.json和yarn.lock不同步时,如何在纱线安装时发生纱线故障?

现在,开发人员添加了一个npm @ 4库,它只改变了package.json,当然不是yarn.lock。

我本来预计yarn install命令会在构建服务器上崩溃,但纱线对我来说意外的行为却是 - 在最新版本中添加这些库,然后更新远程上的yarn.lock:

$ yarn install 
warning ../package.json: No license field 
[1/4] Resolving packages... 
[2/4] Fetching packages... 
warning [email protected]: The platform "linux" is incompatible with this module. 
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation. 
[3/4] Linking dependencies... 
[4/4] Building fresh packages... 
success Saved lockfile. 
Done in 5.07s. 

除了我打算的目的,因为构建作业不会将yarn.lock返回到存储库。我希望每个开发者对他们正在检查的版本负责。

因此,如果package.json和yarn.lock不同步,是否有办法让yarn install退出并显示错误代码?

+0

我打开[纱线的GitHub库的问题(https://github.com/yarnpkg/yarn/issues/4147) – k0pernikus

回答

1

你想要的--frozen-lockfile参数:

$ yarn install --frozen-lockfile 
yarn install v0.27.5 
warning ../package.json: No license field 
[1/4] Resolving packages... 
error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.