ProjectStack
npm

npm ERR! code EPERM — operation not permitted

npm tried to perform a file operation (read, write, or execute) that the operating system blocked due to insufficient permissions. Common on Windows with antivirus or file locking.

Common causes

  • Another process (antivirus, IDE, another npm process) has the file locked on Windows
  • You're trying to install to a directory your user account doesn't own
  • Windows Defender or antivirus is scanning and locking files during install
  • Running npm in a system-protected directory without elevated permissions

How to fix it

  1. Close your IDE and any terminals that might have the project open, then retry
  2. On Windows, try running your terminal as Administrator
  3. Add node_modules to your antivirus exclusions list for the project directory
  4. Delete node_modules completely and reinstall: rmdir /s node_modules && npm install

Example

npm ERR! code EPERM npm ERR! syscall rename npm ERR! path C:\Users\user\project\node_modules\.staging\lodash-1234 npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted

Running npm install on Windows while antivirus software is scanning the directory

Have a different error?

Paste any error message into the Error Translator to get an instant explanation.