Solution to npm install "npm ERR! Error: EPERM: operation not permitted" error

I was trying to install pngquant imagemin plugin using this command:

  
npm install imagemin-pngquant
  

... in Minimalist GNU for Windows running in Windows 10 64-bit OS. And I got this errors:

  
npm ERR! Windows_NT 10.0.10240
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "imagemin-mozjpeg"
npm ERR! node v4.1.2
npm ERR! npm  v2.14.4
npm ERR! path C:\xampp\htdocs\node_modules\imagemin-mozjpeg\node_modules\mozjpeg\node_modules\logalot\node_modules\squeak\node_modules\lpad-align\node_modules\meow\node_modules\normalize-package-data\package.json.36eee2f8a596a53005b643f9a2de1c98
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename

npm ERR! Error: EPERM: operation not permitted, rename 'C:\xampp\htdocs\node_modules\imagemin-mozjpeg\node_modules\mozjpeg\node_modules\logalot\node_modules\squeak\node_modules\lpad-align\node_modules\meow\node_modules\normalize-package-data\package.json.36eee2f8a596a53005b643f9a2de1c98' -> 'C:\xampp\htdocs\node_modules\imagemin-mozjpeg\node_modules\mozjpeg\node_modules\logalot\node_modules\squeak\node_modules\lpad-align\node_modules\meow\node_modules\normalize-package-data\package.json'
npm ERR!     at Error (native)
npm ERR!  { [Error: EPERM: operation not permitted, rename 'C:\xampp\htdocs\node_modules\imagemin-mozjpeg\node_modules\mozjpeg\node_modules\logalot\node_modules\squeak\node_modules\lpad-align\node_modules\meow\node_modules\normalize-package-data\package.json.36eee2f8a596a53005b643f9a2de1c98' -> 'C:\xampp\htdocs\node_modules\imagemin-mozjpeg\node_modules\mozjpeg\node_modules\logalot\node_modules\squeak\node_modules\lpad-align\node_modules\meow\node_modules\normalize-package-data\package.json']
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\xampp\\htdocs\\node_modules\\imagemin-mozjpeg\\node_modules\\mozjpeg\\node_modules\\logalot\\node_modules\\squeak\\node_modules\\lpad-align\\node_modules\\meow\\node_modules\\normalize-package-data\\package.json.36eee2f8a596a53005b643f9a2de1c98',
npm ERR!   dest: 'C:\\xampp\\htdocs\\node_modules\\imagemin-mozjpeg\\node_modules\\mozjpeg\\node_modules\\logalot\\node_modules\\squeak\\node_modules\\lpad-align\\node_modules\\meow\\node_modules\\normalize-package-data\\package.json' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\xampp\htdocs\npm-debug.log
  

I have tried to run the Minimalist GNU as Administrator but after several retries I still getting those errors. The errors gone after I disabled my anti-virus (Avast):

npm install imagemin plugin success install

If you're still getting those errors after disabling your anti-virus for first run, try it to run for several times until you get it to install successfully.

Comments

Thanks! I was wondering what had gone wrong when I got this working on a project. Seems that MalwareBytes interferes with npm wanting to write files to the system i guess.

I spent hours trying all sorts of nonsense before finding this site in google search despair. Turning off MalwareBytes made it work instantly.

Thanks for publishing this. Disabling MalwareBytes fixed my problem as well.

Thank you very much for sharing this. I was repairing npm for a week, couldn't install anything and after reading this and disabling Malwarebytes it finally worked. Thank you again!

I ran command prompt as administrator, installed typescript@* --force and npm -i --force there. It worked for me

run npm in console in 'Admin' mode …

New antivirus in windows 10 security was blocking write permissions to the folder. In particular "Tamper Protection" seems to have been causing the issue on my install

I noticed deleting my folder and installing again and then install running the yarn add command again works fine for me, I investigated further only to find out this happens only when I have the server running and It makes sense that certain resources can't be modified when already in use by another system. Hope this helps.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.