How to solve the npm ERR! Error EPERM operation not permitted

12 min read

If you a run npm install command to install the packages in our package.json file sometimes you will see the following error in your terminal.

npm ERR! code EPERM
npm ERR! syscall rename
npm ERR! path C:\Users\mypc\AppData\Roaming\npm\node_modules\expo-cli\node_modules\package.json.
npm ERR! dest C:\Users\mypc\AppData\Roaming\npm\node_modules\package.json
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, rename

This above error is occurred due to the package-lock.json file is corrupted in your project, to solve the error, follow the below steps.

  1. First, stop the development server.
  2. Clean the npm cache by using the following command.
npm cache clean --force
  1. Delete the node_modules folder and package-lock.json file using:
rm -rf node_modules package-lock.json

or you can delete it manually by right-clicking on it and select the delete option.

  1. Now, re-install the npm packages again by running the below command.
npm install
  1. Start the development server using the appropriate command, like npm start or npm run dev. It will work successfully without any errors.

If you are still facing the same error, then close and vscode editor and open it again and follow the above mentioned steps.