简体   繁体   中英

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.

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:

  1. All your workspaces have "private": true in each of their package.json (same level as name , private , source ).
  2. Check that you have added your workspaces inside a "workspaces" key in the main package.json
  3. When you're executing yarn workspaces myworkspace myworkspace matches the name of your workspace in its 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.

The same error appears for me, I discovered that I had added .yarnrc.yml by mistake. After deleting the file and its reference in yarn-berry.cjs I had the solution and the project ran在此处输入图像描述

I have met the same case .

remove the yarnrc.yml and it worked .

ls -a

rm .yarnrc.yml

it is worked for me .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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