How To fix Yarn Error: EPERM: operation not permited
Back

How To fix Yarn Error: EPERM: operation not permited

Requirements

  • Code Editor
  • Windows 10

Problem

I had this error pop to me during coding a Gatsby project, I just saved some file and realized that I needed a certain library, so then tried to install it with the usual:

yarn add some-library

and there it was, the unfortunate error:

yarn add some-library Yarn Error: EPERM: operation not permited, unlink "..."

Solution

Corrupted node_modules folder

So upon some research, I decided to delete the node_modules folder, a pretty common way to solve local errors. Go to the folder that your project is hosted, then:

rmdir /s node_modules

then install all dependencies again:

rmdir /s node_modules yarn install

Update your version

What also might be a good idea is to update your version. Some bugs may also appear after stable versions of programs, so it is a possibility that could happen these types of bugs. To update Yarn on Windows you can use :

choco upgrade yarn

While is the recommended way to update , you also can install via like so:

npm install -g yarn

Aditional information

2025 Andrei T.F.
with Next.js