Skip to content

npm and Node.js errornpm: “Error: EPERM: operation not permitted, rename / unlink”

npm install, npm ci or a Node.js script fails with npm error code EPERM (npm ERR! on older versions) and Error: EPERM: operation not permitted, rename '...node_modules\...' (or unlink, mkdir, open). The operating system refused the file operation outright. On Windows that almost always means another program has the file open; on macOS it usually means a protected folder.

Short answer

Stop everything that might hold files in the project open: the dev server, watchers, your editor’s TypeScript server, and other terminals. Then delete node_modules and run npm install again. If it keeps happening on Windows, exclude the project folder from antivirus scanning and move it out of a OneDrive or other synced folder. On macOS, give your terminal access to the folder (Desktop and Documents are protected). Do not reach for sudo or an administrator terminal first.

Why the operation was refused, and the fix

  1. 01

    A running program has the file open (Windows)

    “EPERM (Operation not permitted): An attempt was made to perform an operation that requires elevated privileges.” Node.js, Errors: common system errors

    Windows will not rename or delete a file another process has open. npm renames folders in node_modules during an install, so a running dev server, a file watcher, an editor or a second npm process makes it fail. Stop them, then reinstall from a clean state. Node.js describes EPERM in general terms; on Windows the usual reason is a locked file, not missing administrator rights.

    # PowerShell, in the project folder, with dev servers and editors closed
    Remove-Item -Recurse -Force node_modules
    npm install
  2. 02

    Antivirus or OneDrive locks files

    Real-time antivirus scanning and sync tools (OneDrive, Dropbox, Google Drive) open each new file as npm writes it, and the rename that follows fails. Exclude the project and npm cache folders from scanning, or move projects to a folder that does not sync, such as C:\dev.

  3. 03

    A protected folder on macOS

    macOS blocks apps from Desktop, Documents and Downloads until you allow them, and returns EPERM even to the owner. Allow your terminal or editor under System Settings, Privacy and Security, Files and Folders (or Full Disk Access), or keep projects outside those folders.

  4. 04

    EPERM inside the npm cache

    “Note that this is typically unnecessary, as npm's cache is self-healing and resistant to data corruption issues.” npm Docs, npm cache: clean

    If the path in the error is inside npm-cache (%LocalAppData%\npm-cache on Windows, ~/.npm elsewhere), verify the cache rather than deleting it by hand. If files there were created by an administrator or sudo run, fix their owner instead of running npm as administrator again.

    npm cache verify

Checked against the vendor’s docs on : Node.js: Errors (common system errors); npm Docs: npm cache.

Rather hand it over?

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

Related: npm “EACCES: permission denied” · Node.js “ENOENT: no such file or directory” · npm and pnpm “ELIFECYCLE”

Questions

More on this error

What is the difference between EPERM and EACCES?

EACCES means your user lacks permission on that file or folder, which a change of owner fixes. EPERM means the operating system refused the operation itself, usually because the file is locked, protected or read-only.

Should I run npm as administrator?

Not as a fix. It can hide a locked-file problem once, and it leaves files owned by the administrator that cause permission errors later. Find what holds the file open instead.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.

A different error?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.