nvm: nvm install fails complaining about prefix, despite not being set

I am on a linux (ubuntu) machine, just getting started with nvm. (removed all prior installations of node, npm, and n)

$ nvm install stable
Downloading https://nodejs.org/dist/v6.1.0/node-v6.1.0-linux-x64.tar.xz...
######################################################################## 100.0%
nvm is not compatible with the npm config "prefix" option: currently set to "/home/dominic/Github/dominicbarnes/dotfiles/nvm/versions/node/v6.1.0"
Run `nvm use --delete-prefix v6.1.0` to unset it.

I’ve seen this documented around in the readme, and I read the related tickets. However, I did not set any custom prefix at any point. The instructions it gives work for the time, but the error shows right back up for each new terminal session.

I suspect this is because I don’t have any version of node/npm installed at the system level, so whatever is trying to look for the broken prefix value may be getting unexpected behavior, but I’m not sure. (see next comment below, I think I’ve ruled this out)

The prefix option that nvm reports to me appears to be generated on it’s own, as I don’t have a $PREFIX or $NPM_CONFIG_PREFIX option anywhere in my env. (nor is there a profile=... in my ~/.npmrc)

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 24 (9 by maintainers)

Commits related to this issue

Most upvoted comments

I had this issue for the past week, and I finally sat down and took two hours to fix this. Here is what worked for me:

First of all, I wanted to keep the global node modules. So I ran npm ls -g --depth 0 to list all the main once for reinstallation. Just copy and paste the list to a text editor.

Then it was about removing all traces of NVM, Node, and NPM:

brew uninstall node; 
brew prune;
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
sudo rm -f /usr/local/bin/npm /usr/local/lib/dtrace/node.d;
rm -rf ~/.nvm
rm -rf ~/.npm

Then I used https://github.com/lukechilds/zsh-nvm to install NVM again (I am using Oh-My-ZSH).

Next step, installing the latest Node version that I wanted nvm install --lts and followed by that I set the default nvm alias default and then installed my global packages again.

I finally have a system that’s working again and not nagging me about this damn PREFIX thing 👍 .

Ah. Yes, that’s the problem. nvm does not currently work with symlinks. (related, #617 and https://github.com/creationix/nvm/issues/1031#issuecomment-194044829)

@rauliyohmc it’s likely because $HOME has Rauliyohmc, and npm config get prefix is reporting rauliyohmc. One possible fix is to lowercase your username - are you on a case-insensitive filesystem?

@p4ali nvm is not supported via homebrew (as the homebrew formula indicates). brew uninstall nvm, and then properly install nvm with the curl script in the readme, and your problem should go away.

That was it @ljharb, thanks a lot 🤖