9

Windows 10 1703
Node 6.11.2
npm 5.4.0

Everytime I try to install an npm package (ex: npm i gulp-notify), I receive the following error:


npm ERR! path C:\Users\web-dev\Desktop\barber\node_modules\fsevents\node_modules\ansi-regex\package.json
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\web-
dev\Desktop\barber\node_modules\fsevents\node_modules\ansi-regex\package.json' npm ERR! at Error (native)
npm ERR! { Error: EPERM: operation not permitted, unlink 'C:\Users\web-dev\Desktop\barber\node_modules\fsevents\node_modules\ansi-regex\package.json'
npm ERR! at Error (native)
npm ERR! stack: 'Error: EPERM: operation not permitted, unlink \'C:\Users\web-dev\Desktop\barber\node_modules\fsevents\node_modules\ansi-regex\package.json\'\n at Error (native)',
npm ERR! errno: -4048,
npm ERR!
code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR!
path: 'C:\Users\web-dev\Desktop\barber\node_modules\fsevents\node_modules\ansi-regex\package.json' }
npm ERR! npm ERR! Please try running this command again as root/Administrator.


I ran cmd as administrator
I checked folder permissions
I cleared cache even though npm says it does it by itself
I changed npm prefix to C:\Users\User Name\AppData\Roaming\npm
Nothing helps.

Please advise.

vimuth
  • 5,064
  • 33
  • 79
  • 116
Serhii Borovskyi
  • 771
  • 2
  • 7
  • 17
  • I guess some process locks your files by accessing them (probably your code editor?). If possible, disable file locking on your OS. – ideaboxer Sep 03 '17 at 09:37
  • I fixed the issue by adding -g flag to the installation command. Please close the question. – Serhii Borovskyi Sep 03 '17 at 13:49
  • 1
    I downgraded back to npm 5.3.0 and everything works well again. Attempted all the usual remedies, I think something in npm is locking itself out. – Gary Sep 03 '17 at 16:35
  • I thought of that as well because this stuff stopped working after node update. – Serhii Borovskyi Sep 03 '17 at 17:01
  • I do not believe this is a duplicate. Same error, but likely a different cause. Downgrading to 5.3.0 fixed it for me as well. I don't have any other programs open. – Sidney Sep 11 '17 at 21:19
  • After huge struggle found the solution for me .. "Create new folders" mkdir E:\Buildagent\npm mkdir E:\Buildagent\npm-cache "move npm prefix and the cache" robocopy c:\Users\the-build-user\AppData\Roaming\npm E:\Buildagent\npm robocopy c:\Users\the-build-user\AppData\Roaming\npm-cache E:\Buildagent\npm-cache /E /MOVE "Update the npm config for prefix and cache" npm config set prefix E:\Buildagent\npm npm config set cache E:\Buildagent\npm-cache https://alastaircrabtree.com/fixing-intermittant-eperm-operation-not-permitted-on-npm-install/ – Prageeth godage Sep 12 '17 at 05:22

1 Answers1

1

Apparently I was trying to install packages locally instead of globally without the -g flag. Sorry about that. All is working now.

Serhii Borovskyi
  • 771
  • 2
  • 7
  • 17