纱线 - 命令纱线导入错误:您的锁文件中似乎不存在此包;尝试进行安装以更新您的分辨率 [英] 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内部错误:project-middleware@workspace::.:您的锁文件中似乎没有这个包;尝试进行安装以更新您的分辨率在 J.getCandidates (/Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:2:325115)在 i.getCandidates (/Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:2:314232)在/Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:2:335605在 Array.map (<匿名>)在 Ae.resolveEverything (/Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:2:335321)在异步 Ae.applyLightResolution (/Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:2:357937)在异步 Ae.restoreInstallState (/Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:2:357667)在异步 Ke.execute (/Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:2:98394)在异步 Ke.validateAndExecute (/Users/jgil/Development/BerserkerStudio/project_middleware/.yarn/releases/yarn-berry.cjs:2:626801)在 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
文件.删除它.
还要检查一下:
- 您所有的工作区在每个
package.json
中都有"private:true"
(与name
、私有
,源
). - 检查您是否已将工作区添加到主
package.json
的 - 当您执行
yarn workspaces myworkspace
时,myworkspace
与package.json
中的工作区名称相匹配.在我的例子中,components
文件夹内的工作区名称称为@schon/components
,所以我需要将其寻址为yarn workapces @schon/components
代替.
"workspaces"
键中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.
Nevertheless, I'm getting the following error with $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.
Could it be a problem with either the version of Node.js or any other component I'm using?
The problem in here seems to be an existing yarn.lock
file inside of one of the workspaces. Deleting it solves the problem.
More info:
Example: 3 workspaces: 2 create-react-app (app
, home
) and one shared component: (components
)
Inside the component
folder a lingering yarn.lock
file exists. Remove it.
Also check that:
- All your workspaces have
"private:true"
in each of theirpackage.json
(same level asname
,private
,source
). - Check that you have added your workspaces inside a
"workspaces"
key in the mainpackage.json
- When you're executing
yarn workspaces myworkspace
myworkspace
matches the name of your workspace in itspackage.json
. In my case, the name of the workspace inside thecomponents
folder is called@schon/components
, so I need to address it asyarn worksapces @schon/components
instead.
这篇关于纱线 - 命令纱线导入错误:您的锁文件中似乎不存在此包;尝试进行安装以更新您的分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!