ProjectStack
npm

Error: EPERM: operation not permitted, unlink

Node.js or npm tried to delete a file but the operating system blocked it. On Windows, this usually means the file is locked by another process such as antivirus software or your IDE.

Common causes

  • Windows Defender or antivirus software has the file locked for scanning
  • An IDE like VS Code has a file handle open on the file being deleted
  • The file is read-only or in a read-only directory
  • Another npm or node process is currently using the file

How to fix it

  1. Close your IDE, code editor, and any terminals using the project, then retry
  2. Add the project's node_modules directory to your antivirus exclusion list
  3. On Windows, try: rmdir /s /q node_modules and then npm install
  4. Restart your computer to release all file locks, then delete node_modules

Example

Error: EPERM: operation not permitted, unlink 'C:\Users\user\project\node_modules\.cache\file.js'

Running npm install --force or deleting node_modules on Windows with antivirus active

Have a different error?

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