[英]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.删除它可以解决问题。
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:还要检查:
"private": true
in each of their package.json
(same level as name
, private
, source
)."private": true
在他们的每个package.json
(与name
、 private
、 source
相同的级别)。"workspaces"
key in the main package.json
package.json
的"workspaces"
键中添加了工作区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
。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.