![](/img/trans.png)
[英]error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`
[英]Yarn - Command yarn import error: This package doesn't seem to be present in your lockfile; try to make an install to update your resolutions
我正在尋找在我的項目中一起使用 yarn 和 npm,如果我發現yarn
對我的特定情況有用,我可以將我的項目移動到僅使用yarn
。
不過,我收到以下錯誤$yarn import
:
local:project_middleware jgil$ yarn import
Internal Error: project-middleware@workspace:.: This package doesn't seem to be present in your lockfile; try to make an install to update your resolutions
at J.getCandidates (/Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:2:325115)
at i.getCandidates (/Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:2:314232)
at /Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:2:335605
at Array.map (<anonymous>)
at Ae.resolveEverything (/Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:2:335321)
at async Ae.applyLightResolution (/Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:2:357937)
at async Ae.restoreInstallState (/Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:2:357667)
at async Ke.execute (/Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:2:98394)
at async Ke.validateAndExecute (/Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:2:626801)
at async j.run (/Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:17:3854)
我已經運行$yarn set version berry
並一次又一次地嘗試了刪除node_modules
目錄、運行npm install
等的不同組合,但沒有任何東西可以讓它工作......不知道缺少什么。
這可能是 Node.js 版本或我正在使用的任何其他組件的問題嗎?
這里的問題似乎是其中一個工作空間內的現有yarn.lock
文件。 刪除它可以解決問題。
示例:3 個工作區:2 個 create-react-app ( app
, home
) 和一個共享組件:( components
)
在component
文件夾中存在一個揮之不去的yarn.lock
文件。 去掉它。
還要檢查:
"private": true
在他們的每個package.json
(與name
、 private
、 source
相同的級別)。package.json
的"workspaces"
鍵中添加了工作區yarn workspaces myworkspace
myworkspace
時,它的package.json
與您的工作區名稱匹配。 在我的例子中, components
文件夾內的工作空間的名稱稱為@schon/components
,所以我需要將其命名為yarn worksapces @schon/components
。我也遇到過同樣的情況。
刪除 yarnrc.yml 並且它起作用了。
ls -a
rm .yarnrc.yml
它對我有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.