How to solve the npm ERR! Error: EPERM: operation not permitted
In this tutorial, we are going to learn about how to solve the npm ERR! Error: EPERM: operation not permitted, rename error.
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.
-
First, stop the development server.
-
Clean the
npm
cache by using the following command.
npm cache clean --force
- Delete the
node_modules
folder andpackage-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.
- Now, re-install the npm packages again by running the below command.
npm install
- Start the development server using the appropriate command, like
npm start
ornpm 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.