簡體   English   中英

Yarn - 命令紗線導入錯誤:這個包似乎不存在於您的鎖定文件中; 嘗試進行安裝以更新您的分辨率

[英]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文件。 去掉它。

在此處輸入圖像描述

還要檢查:

  1. 你所有的工作空間都有"private": true在他們的每個package.json (與nameprivatesource相同的級別)。
  2. 檢查您是否已在主package.json"workspaces"鍵中添加了工作區
  3. 當您執行yarn workspaces myworkspace myworkspace時,它​​的package.json與您的工作區名稱匹配。 在我的例子中, components文件夾內的工作空間的名稱稱為@schon/components ,所以我需要將其命名為yarn worksapces @schon/components

同樣的錯誤出現在我身上,我發現我錯誤地添加了.yarnrc.yml 刪除文件及其在yarn-berry.cjs中的引用后,我有了解決方案並且項目運行了在此處輸入圖像描述

我也遇到過同樣的情況。

刪除 yarnrc.yml 並且它起作用了。

ls -a

rm .yarnrc.yml

它對我有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM