简体   繁体   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

I'm looking for using yarn and npm together in my project and if I find yarn useful for my particular case, I could move my project to use yarn only.我正在寻找在我的项目中一起使用 yarn 和 npm,如果我发现yarn对我的特定情况有用,我可以将我的项目移动到仅使用yarn

Nevertheless, I'm getting the following error with $yarn import :不过,我收到以下错误$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)

I have already run $yarn set version berry and tried out again and again with different combinations of removing the node_modules directory, running npm install , etc. and nothing gets to make it work... no idea of what's missing.我已经运行$yarn set version berry并一次又一次地尝试了删除node_modules目录、运行npm install等的不同组合,但没有任何东西可以让它工作......不知道缺少什么。

Could it be a problem with either the version of Node.js or any other component I'm using?这可能是 Node.js 版本或我正在使用的任何其他组件的问题吗?

The problem in here seems to be an existing yarn.lock file inside of one of the workspaces.这里的问题似乎是其中一个工作空间内的现有yarn.lock文件。 Deleting it solves the problem.删除它可以解决问题。

More info:更多信息:

Example: 3 workspaces: 2 create-react-app ( app , home ) and one shared component: ( components )示例:3 个工作区:2 个 create-react-app ( app , home ) 和一个共享组件:( components )

文件夹结构

Inside the component folder a lingering yarn.lock file exists.component文件夹中存在一个挥之不去的yarn.lock文件。 Remove it.去掉它。

在此处输入图像描述

Also check that:还要检查:

  1. All your workspaces have "private": true in each of their package.json (same level as name , private , source ).你所有的工作空间都有"private": true在他们的每个package.json (与nameprivatesource相同的级别)。
  2. Check that you have added your workspaces inside a "workspaces" key in the main package.json检查您是否已在主package.json"workspaces"键中添加了工作区
  3. When you're executing yarn workspaces myworkspace myworkspace matches the name of your workspace in its package.json .当您执行yarn workspaces myworkspace myworkspace时,它​​的package.json与您的工作区名称匹配。 In my case, the name of the workspace inside the components folder is called @schon/components , so I need to address it as yarn worksapces @schon/components instead.在我的例子中, components文件夹内的工作空间的名称称为@schon/components ,所以我需要将其命名为yarn worksapces @schon/components

The same error appears for me, I discovered that I had added .yarnrc.yml by mistake.同样的错误出现在我身上,我发现我错误地添加了.yarnrc.yml After deleting the file and its reference in yarn-berry.cjs I had the solution and the project ran删除文件及其在yarn-berry.cjs中的引用后,我有了解决方案并且项目运行了在此处输入图像描述

I have met the same case .我也遇到过同样的情况。

remove the yarnrc.yml and it worked .删除 yarnrc.yml 并且它起作用了。

ls -a ls -a

rm .yarnrc.yml rm .yarnrc.yml

it is worked for me .它对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM