Skip to content

Errors using yarn Package Manager

I have been using npm to install packages using sudo before each command. Considering that this is a bad practice, I have installed yarn in order to manage my packages. After installing yarn and running a package installation, I am obtaining the following errors:

info No lockfile found.

Should I manually create this file, or yarn should be creating one on its own?

warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.

If I clear the package-lock.json file, then npm will no longer find the packages. Do I need to uninstall all the packages that were initially installed using npm, and re-install everything if I wish to exclusively use yarn in the future? There are quite a few packages.

error An unexpected error occurred: “EACCES: permission denied, mkdir ‘/home/username/node_modules/cacheable-request'”.

I suppose that this error is due to the fact that I had initially installed nodes with sudo permission. How can I fix this permission issue?



Assuming you are using Linux (because of the sudo command).

  • info No lockfile found.

The first time yarn successfully installs dependencies it create the file.

  • warning package-lock.json found

Just a Warning is not recommended to use both yarn and NPM but is not a problem.

  • error An unexpected error occurred: “EACCES: permission denied

You should be the owner of /home/<you_username>/node_modules to check this run this command ls -l ~/node_modules if the owner is the root (because of use sudo npm) you can change to you again running sudo chown -R $USER ~/node_modules
Then you should be able to run yarn again to install all your dependencies.