2017-08-10 35 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`.