Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing error in yarn start command says This package doesn't seem to be present in your lockfile; try to make an install to update your resolutions

The error shown when yarn start command is given

Error details:

Internal Error: confusion@workspace:.: This package doesn't seem to be present in your lockfile; try to make an install to update your resolutions
    at J.getCandidates (C:\Users\risha\Desktop\Front-End Web Development with React\.yarn\releases\yarn-berry.js:2:276872)
    at i.getCandidates (C:\Users\risha\Desktop\Front-End Web Development with React\.yarn\releases\yarn-berry.js:2:266282)
    at C:\Users\risha\Desktop\Front-End Web Development with React\.yarn\releases\yarn-berry.js:2:286432    at C:\Users\risha\Desktop\Front-End Web Development with React\.yarn\releases\yarn-berry.js:57:349928
    at new Promise (<anonymous>)
    at e.exports (C:\Users\risha\Desktop\Front-End Web Development with React\.yarn\releases\yarn-berry.js:57:349910)
    at o (C:\Users\risha\Desktop\Front-End Web Development with React\.yarn\releases\yarn-berry.js:57:349611)
    at C:\Users\risha\Desktop\Front-End Web Development with React\.yarn\releases\yarn-berry.js:57:349684
    at C:\Users\risha\Desktop\Front-End Web Development with React\.yarn\releases\yarn-berry.js:57:349727
    at new Promise (<anonymous>)

My package.json file is

{
  "name": "confusion",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
  }

}

I have tried adding

"scripts":{
  "start":"react-scripts start"
}

But no change in the error.

like image 206
rishabhshailesh Avatar asked Jul 21 '20 13:07

rishabhshailesh


People also ask

How do I install yarn packages?

Step 1 — Installing Yarn Globally The Yarn maintainers recommend installing Yarn globally by using the NPM package manager, which is included by default with all Node. js installations. Use the -g flag with npm install to do this: sudo npm install -g yarn.

Why is yarn command not found?

To solve the error "yarn: command not found", install the yarn package globally by running npm install -g yarn and restart your terminal. If the command fails, run it with sudo and make sure the correct PATH is set in your system's environment variable.

What is resolutions in package json?

resolutions is simply a map of package names and the exact versions of those packages that should be kept in the dependency tree, i.e. the above configuration will remove all versions of webpack that are not 5.6.

Does yarn install from package json?

Install all the dependencies listed within package. json in the local node_modules folder.


2 Answers

Cross-posting from this question:

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)

folder strcuture

Inside the component folder a lingering yarn.lock file exists. Remove it.

enter image description here

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.
like image 105
Jose A Avatar answered Sep 16 '22 16:09

Jose A


It means a certain package is not installed, and you need to install it.

  • Try running yarn install to install the required packages.
  • If this does not work, try deleting the node_modules folder and run yarn install again.
  • If it fails, delete both node_modules folder and yarn.lock file and run yarn install.
like image 29
agrawal-d Avatar answered Sep 18 '22 16:09

agrawal-d