Nvm-windows: Can't upgrade npm right after install of node 8.10

Created on 6 Sep 2018  路  1Comment  路  Source: coreybutler/nvm-windows

I know Windows 7 isn't officially supported, but this doesn't feel like a Windows 7 issue.
I'm not sure what it does feel like, but that's what I'm here to find out.

It looks like 'gentle-fs' doesn't want to rm the file it needs to rm.

My Environment

  • [x] Windows 7 or below (not truly supported due to EOL - see wiki for details)

I'm using NVM4W version:

  • [x] 1.1.7

I have already...

  • [x] read the README to be aware of npm gotchas & antivirus issues.
  • [x] reviewed the wiki to make sure my issue hasn't already been resolved.
  • [x] verified I'm using an account with administrative privileges.
  • [x] searched the issues (open and closed) to make sure this isn't a duplicate.
  • [x] made sure this isn't a question about how to use NVM for Windows, since gitter is used for questions and comments.

My issue is related to (check only those which apply):

  • [x] A standard shell environment (terminal/powershell)

Expected Behavior

npm install -g npm would work.

Actual Behavior

It didn't:

C:\Users\nannp>npm install -g npm
npm ERR! path C:\Program Files\nodejs\npm.cmd
npm ERR! code EEXIST
npm ERR! Refusing to delete C:\Program Files\nodejs\npm.cmd: is outside C:\Program Files\nodejs\node_modules\npm and not a link
npm ERR! File exists: C:\Program Files\nodejs\npm.cmd
npm ERR! Move it away, and try again.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\nannp\AppData\Roaming\npm-cache\_logs\2018-09-06T13_02_02_287Z-debug.log

The mentioned log file ends with:

3446 verbose unlock done using C:\Users\nannp\AppData\Roaming\npm-cache\_locks\staging-dfd8fbf9c1feea0f.lock for C:\Program Files\nodejs\node_modules\.staging
3447 verbose stack Error: Refusing to delete C:\Program Files\nodejs\npm.cmd: is outside C:\Program Files\nodejs\node_modules\npm and not a link
3447 verbose stack     at clobberFail (C:\Users\nannp\AppData\Roaming\nvm\v8.10.0\node_modules\npm\node_modules\gentle-fs\lib\rm.js:121:12)
3447 verbose stack     at isSafeToRm (C:\Users\nannp\AppData\Roaming\nvm\v8.10.0\node_modules\npm\node_modules\gentle-fs\lib\rm.js:114:15)
3447 verbose stack     at C:\Users\nannp\AppData\Roaming\nvm\v8.10.0\node_modules\npm\node_modules\gentle-fs\lib\rm.js:54:5
3447 verbose stack     at LOOP (C:\Users\nannp\AppData\Roaming\nvm\v8.10.0\node_modules\npm\node_modules\slide\lib\chain.js:7:26)
3447 verbose stack     at C:\Users\nannp\AppData\Roaming\nvm\v8.10.0\node_modules\npm\node_modules\slide\lib\chain.js:18:7
3447 verbose stack     at C:\Users\nannp\AppData\Roaming\nvm\v8.10.0\node_modules\npm\node_modules\gentle-fs\lib\rm.js:180:7
3447 verbose stack     at C:\Users\nannp\AppData\Roaming\nvm\v8.10.0\node_modules\npm\node_modules\iferr\index.js:13:50
3447 verbose stack     at _readAllLinks (C:\Users\nannp\AppData\Roaming\nvm\v8.10.0\node_modules\npm\node_modules\gentle-fs\lib\rm.js:215:28)
3447 verbose stack     at C:\Users\nannp\AppData\Roaming\nvm\v8.10.0\node_modules\npm\node_modules\iferr\index.js:13:50
3447 verbose stack     at resolveSymlink (C:\Users\nannp\AppData\Roaming\nvm\v8.10.0\node_modules\npm\node_modules\gentle-fs\lib\rm.js:226:22)
3447 verbose stack     at _readAllLinks (C:\Users\nannp\AppData\Roaming\nvm\v8.10.0\node_modules\npm\node_modules\gentle-fs\lib\rm.js:217:5)
3447 verbose stack     at readAllLinks (C:\Users\nannp\AppData\Roaming\nvm\v8.10.0\node_modules\npm\node_modules\gentle-fs\lib\rm.js:212:3)
3447 verbose stack     at C:\Users\nannp\AppData\Roaming\nvm\v8.10.0\node_modules\npm\node_modules\gentle-fs\lib\rm.js:179:5
3447 verbose stack     at C:\Users\nannp\AppData\Roaming\nvm\v8.10.0\node_modules\npm\node_modules\iferr\index.js:13:50
3447 verbose stack     at cb (C:\Users\nannp\AppData\Roaming\nvm\v8.10.0\node_modules\npm\node_modules\slide\lib\async-map.js:47:24)
3447 verbose stack     at C:\Users\nannp\AppData\Roaming\nvm\v8.10.0\node_modules\npm\node_modules\gentle-fs\lib\rm.js:153:16
3448 verbose cwd C:\Users\nannp\
3449 verbose Windows_NT 6.1.7601
3450 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "npm"
3451 verbose node v8.10.0
3452 verbose npm  v5.6.0
3453 error path C:\Program Files\nodejs\npm.cmd
3454 error code EEXIST
3455 error Refusing to delete C:\Program Files\nodejs\npm.cmd: is outside C:\Program Files\nodejs\node_modules\npm and not a link
3456 error File exists: C:\Program Files\nodejs\npm.cmd
3457 error Move it away, and try again.
3458 verbose exit [ 1, true ]

Moving 'npm.cmd' away doesn't really help. Then I can't run npm at all.

Steps to reproduce the problem:

Did a fresh install of nvm on Windows 7, via the installer. Accept all defaults.
Opened a new CMD window. Ran:
nvm install 8.10

  • All good

npm install -g npm

  • All bad, as above.

Most helpful comment

Sorry - My searching skills failed me today...
After submitting, I did a bit more Googling and found the other thread: https://github.com/coreybutler/nvm-windows/issues/300

Thanks to @Jeff-Lewis for this simple gem:
Since this IS a Windows problem, save and run the commands below in a .bat file:
OR MAYBE RUN THE COMMANDS MANUALLY ONE AT A TIME, since if one step fails, the following steps could go from bad to worse...

pushd %ProgramFiles%\nodejs
del npm npm.cmd
move node_modules\npm node_modules\npm2
call node node_modules\npm2\bin\npm-cli.js i npm@latest -g
rmdir /S /Q node_modules\npm2
popd
pause

Worked perfectly to get npm to V6.4.1

Anyone else feel like this npm world is a house of cards at times???

>All comments

Sorry - My searching skills failed me today...
After submitting, I did a bit more Googling and found the other thread: https://github.com/coreybutler/nvm-windows/issues/300

Thanks to @Jeff-Lewis for this simple gem:
Since this IS a Windows problem, save and run the commands below in a .bat file:
OR MAYBE RUN THE COMMANDS MANUALLY ONE AT A TIME, since if one step fails, the following steps could go from bad to worse...

pushd %ProgramFiles%\nodejs
del npm npm.cmd
move node_modules\npm node_modules\npm2
call node node_modules\npm2\bin\npm-cli.js i npm@latest -g
rmdir /S /Q node_modules\npm2
popd
pause

Worked perfectly to get npm to V6.4.1

Anyone else feel like this npm world is a house of cards at times???

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ctsstc picture ctsstc  路  3Comments

Deilan picture Deilan  路  4Comments

snerte picture snerte  路  5Comments

fredericrous picture fredericrous  路  3Comments

eliavmaman picture eliavmaman  路  6Comments