An unexpected error occurred: "EPERM: operation not permitted in Yarn

Viewed 43773

I am having problems installing new npm packages with Yarn. Every time I go on to add a new package it's throwing me this error. But when I delete my node_modules folder and run Yarn, everything works fine. Again when I try to add another package, it throws me the same error. Any solutions, I am having a headache right now.

enter image description here

8 Answers

In Windows first stop the development server and then try to install package.

Stopping the server before running yarn add solved mine.

I had same problem, I went into the Task Manager (CTRL+SHIFT+ESC) and killed all the NodeJs processes.

Press "Ctrl+C" to stop the server and repeat the installation.

if you're using visual studio code, cmd, or Windows Terminal, close it and run it in administrator mode. Usually, the reason for that error message is a result of limited privilege giving to the editor or npm or Yarn if you're using that.

did you try to open CDM as run as administrator or if with wsl terminal try to use sudo like sudo yarn

This is likely due to you creating your project within the windows /mnt directory structure

Rerun inside the ~/home folder

(accessible within windows @ //wsl$/

Sometimes when this occurs, you may first try to uncheck node_modules folder to read only. If it is not working try to stop the running server and install your packages and then restart the server.

Related