Unrecoverable error while transferring npm folder

What I Wanted to Do

I have decided to move npm directory from c:\Users\... to installation destination C:\nodejs\....
I forgot about Windows specific, which does not allow coexistence of directories and files with the same name in the same directory.
It would be nice if npm can help user to refresh his memory in such case.

What Happened Instead

npm silently moved directory to incorrect location and broke himself.

Reproduction Steps

  1. Install node-v10.15.1-x64.msi into C:\nodejs\ directory.
  2. Open cmd.exe and type npm config set prefix "C:\nodejs\npm" --global.
  3. Type npm config list to be sure if all is fine. Result: things are not fine, error pops out: Error: EEXIST: file already exists, mkdir 'C:\nodejs\npm'.
  4. Try to revert to original setting: npm config set prefix "c:\Users\Vort\appdata\Roaming\npm" --global (Change Vort to your username). And same error shows again.


OS: Windows 7 SP1 x64

Platform Info

$ npm --versions
{ npm: '6.4.1',
  ares: '1.15.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.34.0',
  node: '10.15.1',
  openssl: '1.1.0j',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.2',
  v8: '',
  zlib: '1.2.11' }
$ node -p process.platform

I am not sure what the path should look like to work, but to delete the bad setting and get back to default behaviour:

npm config delete --global prefix

Documentation for config: https://docs.npmjs.com/cli/config

This does not work:

I was able to revert settings by removing c:\Users\Vort\AppData\Roaming\npm\etc\npmrc.
The problem is that npm allows this to happen.

Oh! Thanks for update.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.