I see others have similar problems, but I have not found a solution.
Installation Steps
I performed the following to install nvm
and node
on Ubuntu / WSL2, as per these instructions:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
mkdir ~/.npm-global
npm config set prefix ~/.npm-global
cat >> ~/.bashrc <<EOF
export PATH="$HOME/.npm-global/bin:$PATH"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" 1>&2 # Loads nvm
EOF
nvm install node
$ which npm
/home/mslinn/.nvm/versions/node/v17.6.0/bin/npm
$ cat ~/.npmrc
fund=false
prefix=/home/mslinn/.npm-global
Now the Problem
$ source ~/.bashrc
Your user’s .npmrc file (${HOME}/.npmrc)
has a `globalconfig` and/or a `prefix` setting, which are incompatible with nvm.
Run `nvm use --delete-prefix v17.6.0 --silent` to unset it.
Removing the prefix
setting ignores the manually changed default directory for npm.