"Error: EPERM: operation not permitted, rename" on npm install

Paul Knopf's Avatar

Paul Knopf

27 Sep, 2015 06:51 PM

Occasionally, my build will fail. Re-running it will cause it to be fixed.

Here is a failed build example. https://ci.appveyor.com/project/theonlylawislove/skimur/build/1.0.36

Here is the output.

Build started
Install-Product node 4.1.1
Uninstalling node 0.12.7 (x86)... 
Installing node 4.1.1 (x86)... 
git clone -q --branch=master https://github.com/skimur/skimur.git C:\projects\skimur
git checkout -qf 311b866e5c157de4f78765ef1b75cc8a5a9b318f
npm install
npm WARN package.json @ No repository field.
npm WARN package.json @ No license field.
npm WARN deprecated gulp-clean@0.3.1: use gulp-rimraf instead
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v4.1.1
npm ERR! npm  v2.14.4
npm ERR! path C:\Users\appveyor\AppData\Roaming\npm-cache\xtend\4.0.0\package\package.json.b85e97dd2b1da9dcee2e77348b8b3e6b
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\appveyor\AppData\Roaming\npm-cache\xtend\4.0.0\package\package.json.b85e97dd2b1da9dcee2e77348b8b3e6b' -> 'C:\Users\appveyor\AppData\Roaming\npm-cache\xtend\4.0.0\package\package.json'
npm ERR!     at Error (native)
npm ERR!  { [Error: EPERM: operation not permitted, rename 'C:\Users\appveyor\AppData\Roaming\npm-cache\xtend\4.0.0\package\package.json.b85e97dd2b1da9dcee2e77348b8b3e6b' -> 'C:\Users\appveyor\AppData\Roaming\npm-cache\xtend\4.0.0\package\package.json']
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\Users\\appveyor\\AppData\\Roaming\\npm-cache\\xtend\\4.0.0\\package\\package.json.b85e97dd2b1da9dcee2e77348b8b3e6b',
npm ERR!   dest: 'C:\\Users\\appveyor\\AppData\\Roaming\\npm-cache\\xtend\\4.0.0\\package\\package.json',
npm ERR!   parent: 'through2' }
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:\projects\skimur\npm-debug.log
Command exited with code -4048

Any ideas why this fails intermittently?

  1. Support Staff 1 Posted by Feodor Fitsner on 28 Sep, 2015 04:03 AM

    Feodor Fitsner's Avatar

    Looks like it's that nasty Windows-specific error. Searching in Google leads nowhere: https://www.google.ca/search?q=npm+ERR!+Error%3A+EPERM%3A+operation...

    I ran it 100 times and fail ratio was pretty low (4 of 100): https://ci.appveyor.com/project/FeodorFitsner/skimur/history

    I tried updating npm to the latest version, but it failed once anyway.

    Apparently, it's more "stable" on Pro environment where VMs have higher IOPS.

    You may try implementing re-try batch for npm install like shown here: https://github.com/appveyor/ci/blob/master/scripts/nuget-restore.cmd

  2. 2 Posted by DP on 02 Oct, 2015 11:03 PM

    DP's Avatar

    Perhaps AntiVirus software is interfering?

  3. Support Staff 3 Posted by Feodor Fitsner on 02 Oct, 2015 11:44 PM

    Feodor Fitsner's Avatar

    There is like built-in windows defender only, I'm not sure whether it could be disabled.

    - Feodor

  4. 4 Posted by Martin on 02 Nov, 2015 03:05 PM

    Martin's Avatar

    It's a bug in npm:

    You'll have to use --force to avoid cache completely or wait for npm team to implement permanent solution.

  5. 5 Posted by daniel on 31 May, 2016 08:37 AM

    daniel's Avatar

    very silly solution - due to our cvs, the package.json had a write-protection flag :F

  6. 6 Posted by kneumei on 13 Jun, 2016 08:12 PM

    kneumei's Avatar

    I'm seeing this problem running 4.4.5, almost every time. I've added --force flag. Any other ideas?

  7. 7 Posted by womper on 16 Aug, 2016 04:30 PM

    womper's Avatar

    I had the same issue. package.json was in a visual studio 2015 project. My solution was to manually check package.json out for editing. Once i did this, the error went away. No need to add the --force flag. Hope this helps somebody!

  8. 8 Posted by Ilya Finkelshte... on 05 Oct, 2016 10:38 PM

    Ilya Finkelshteyn's Avatar

    Another simple solution recently worked for one of our customers is using appveyor-retry, e.g. appveyor-retry npm install


  9. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:08 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac