Fixing npm err code EPERM: operation not permitted on Windows
Advertisement728 x 90
Fixing npm err code EPERM on Windows
When running npm install or npm cache clean, you might encounter an error like:
npm error code EPERM: operation not permitted, rename 'C:\Users\YourName\AppData\Local\npm-cache\_cacache\tmp\f2a12cbf'
This usually originates on Windows due to file locking issues—either your antivirus, an IDE, or the Node process itself is keeping a file open.
Step 1: Kill Hanging Node Processes
Open PowerShell as Administrator and run:
taskkill /F /IM node.exe
Step 2: Clear the NPM Cache
Forcefully clear your npm cache:
npm cache clean --force
Step 3: Run as Administrator
Sometimes, simple permission limits block npm. Try restarting your terminal or IDE (like VS Code) with "Run as Administrator".
If all else fails, manually delete the node_modules folder and package-lock.json, then install dependencies again.