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
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 install02
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.
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.
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.
- from $450App Fix TicketOne reproducible bug in an existing mobile or web app, diagnosed and fixed.See scope and start
- from $450AI-Built App RescueA Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.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.See scope and start
Related: npm “EACCES: permission denied” · Node.js “ENOENT: no such file or directory” · npm and pnpm “ELIFECYCLE”