Error "operation not permitted" during upgrade from npm 6.10.1 to 6.10.2 on Windows 10

What I Wanted to Do

Upgrade to the new version of npm (6.10.2)

What Happened Instead

I got an error during installation:

npm ERR! Error: EPERM: operation not permitted, open 'C:\Users\myuser\AppData\Roaming\npm\npm'

Reproduction Steps

  1. Execute npm install -g npm

Details

After receiving this error I cannot was not able to use npm until I restarted the shell:

$ npm
bash: /c/Users/myuser/AppData/Roaming/npm/npm: No such file or directory

Somehow I have multiple npms installed on my system, I’m not sure why

>where npm
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
C:\Users\szx\AppData\Roaming\npm\npm.cmd

It seems that now I’m using the one from “Program Files” (version 6.4.1).

After I executed “npm install -g npm” one more time (using the second npm), it installed 6.10.2 successfully.

Output of npm install:

C:\Users\myuser\AppData\Roaming\npm\npx -> C:\Users\myuser\AppData\Roaming\npm\node_modules\npm\bin\npx-cli.js
npm ERR! path C:\Users\myuser\AppData\Roaming\npm\npm
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall open
npm ERR! Error: EPERM: operation not permitted, open 'C:\Users\myuser\AppData\Roaming\npm\npm'
npm ERR!  { Error: EPERM: operation not permitted, open 'C:\Users\myuser\AppData\Roaming\npm\npm'
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, open 'C:\Users\myuser\AppData\Roaming\npm\npm'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'open',
npm ERR!      path: 'C:\\Users\\myuser\\AppData\\Roaming\\npm\\npm' },
npm ERR!   stack: 'Error: EPERM: operation not permitted, open \'C:\\Users\\myuser\\AppData\\Roaming\\npm\\npm\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'open',
npm ERR!   path: 'C:\\Users\\myuser\\AppData\\Roaming\\npm\\npm' }npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\myuser\AppData\Roaming\npm-cache\_logs\2019-07-24T14_30_06_463Z-debug.log

Platform Info

$ npm --versions
    { npm: '6.4.1',     
      ares: '1.10.1-DEV'
      cldr: '32.0',     
      http_parser: '2.8.
      icu: '60.1',      
      modules: '57',    
      napi: '3',        
      nghttp2: '1.32.0',
      node: '8.12.0',   
      openssl: '1.0.2p',
      tz: '2017c',      
      unicode: '10.0',  
      uv: '1.19.2',     
      v8: '6.2.414.66', 
      zlib: '1.2.11' }  

$ node -p process.platform
`win32`