Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvm install fails complaining about prefix, despite not being set #1087

Closed
dominicbarnes opened this issue May 8, 2016 · 24 comments
Closed
Labels
needs followup We need some info or action from whoever filed this issue/PR.

Comments

@dominicbarnes
Copy link

dominicbarnes commented May 8, 2016

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)

@dominicbarnes
Copy link
Author

dominicbarnes commented May 8, 2016

I installed node globally on my system, hoping it would fix my issue. Alas, it did not, so I proceeded to figure out what the npm config looks like:

$ npm config get prefix
/usr

This appears to be some sort of default, as it is not in the env, my npmrc or anywhere else I control.

Since the above description assumes that node/npm isn't installed prior to nvm install ..., I don't think this is entirely relevant. (but I wanted to rule out my lack of a global node/npm installation as a factor)

@dominicbarnes
Copy link
Author

dominicbarnes commented May 8, 2016

I was running on the master, so I figured I would rule that out as the source of my error too. I checked out v0.31.0 (the latest release as far as I can tell) to see if that fixes it, but I get the same error.

@ljharb
Copy link
Member

ljharb commented May 8, 2016

What does nvm debug print out?

How did you install your system node? npm config get prefix should always have a default value, but /usr shouldn't be it.

What happens if you run nvm use --delete-prefix v6.1.0 and then which npm && npm config get prefix?

@ljharb ljharb added the needs followup We need some info or action from whoever filed this issue/PR. label May 8, 2016
@dominicbarnes
Copy link
Author

dominicbarnes commented May 8, 2016

I installed node via nodesource

$ nvm debug
nvm --version: v0.31.0
$SHELL: /bin/bash
$HOME: /home/dominic
$NVM_DIR: '$HOME/.dotfiles/nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: system
which node: /usr/bin/node
which iojs: 
which npm: /usr/bin/npm
npm config get prefix: /usr
npm root -g: /usr/lib/node_modules

However, my original intent was to do w/o the global node, so when I uninstall and re-run nvm debug:

$ nvm debug
nvm --version: v0.31.0
$SHELL: /bin/bash
$HOME: /home/dominic
$NVM_DIR: '$HOME/.dotfiles/nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: none
which node: 
which iojs: 
which npm: 
npm config get prefix: The program 'npm' is currently not installed. You can install it by typing:
sudo apt-get install npm
npm root -g: The program 'npm' is currently not installed. You can install it by typing:
sudo apt-get install npm

And as for those other steps:

$ nvm install 6
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.

$ nvm use --delete-prefix v6.1.0
Now using node v6.1.0 (npm v3.8.6)

$ which npm
/home/dominic/.dotfiles/nvm/versions/node/v6.1.0/bin/npm

$ npm config get prefix
/home/dominic/Github/dominicbarnes/dotfiles/nvm/versions/node/v6.1.0

It looks to me as if the npm being installed by nvm is what is reporting the prefix the way it is.

@ljharb
Copy link
Member

ljharb commented May 8, 2016

aha, i suspect the issue might be capitalization - ie, Github vs github. Is your filesystem case-insensitive, or case-sensitive?

@dominicbarnes
Copy link
Author

dominicbarnes commented May 8, 2016

My fs is case-sensitive, and Github is correct.

I wonder if this has to do with symlinks? My ~/.dotfiles is a symlink to ~/Github/dominicbarnes/dotfiles, in case some sort of link indirection is causing issues here.

In my bashrc, I'm using:

source ~/.dotfiles/nvm/nvm.sh

I'll try using the longer path that isn't behind a symlink to see if that makes a difference.

@dominicbarnes
Copy link
Author

dominicbarnes commented May 8, 2016

Well, it turns out that using:

source ~/Github/dominicbarnes/dotfiles/nvm/nvm.sh`

Then it works, so it appears like there is a problem with "sourcing" it in a directory that is behind a symlink. I think that would be considered a bug, but not sure how best to address it.

@ljharb
Copy link
Member

ljharb commented May 8, 2016

Ah. Yes, that's the problem. nvm does not currently work with symlinks. (related, #617 and #1031 (comment))

@dominicbarnes
Copy link
Author

Oddly enough, this error has shown back up for me on OSX. (despite the fact that I'm not using a symlink, which fixed the error on linux)

@ljharb
Copy link
Member

ljharb commented May 27, 2016

@dominicbarnes can you file a separate issue for your new OS X problem, including nvm debug output?

@ljharb ljharb closed this as completed Jul 20, 2016
@thefonso
Copy link

@dominicbarnes can you link the OS X version of this problem? I am having the same issue. Thanks.

@p4ali
Copy link

p4ali commented Nov 15, 2016

Same problem.

$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.11.6
BuildVersion: 15G31

$ nvm debug
nvm --version: v0.32.1
$SHELL: /bin/zsh
$HOME: /Users/x208032
$NVM_DIR: '/usr/local/opt/nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v7.1.0
which node: $NVM_DIR/versions/node/v7.1.0/bin/node
which iojs: iojs not found
which npm: $NVM_DIR/versions/node/v7.1.0/bin/npm
npm config get prefix: /usr/local/Cellar/nvm/0.32.1/versions/node/v7.1.0
npm root -g: /usr/local/Cellar/nvm/0.32.1/versions/node/v7.1.0/lib/node_modules

@ljharb
Copy link
Member

ljharb commented Nov 15, 2016

@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.

@rgommezz
Copy link

I am having exactly the same issue:

  • System node and npm completely uninstalled
  • macOS Sierra 10.12.1

I installed nvm through the install script:
curl -o- https://raw.github.com/creationix/nvm/v0.32.1/install.sh | bash
The below lines are properly added into my bash_profile

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

After that I installed the LTS version (v6.9.2) through nvm:

nvm install --lts

Getting this message:

image

So, in order to use node I have to run nvm use --delete-prefix v6.9.2, which will work for the current terminal session. However, reopening the terminal makes running node -v to output
-bash: node: command not found, so I have to repeat that command over and over per terminal session prior to any node interaction.

This is how my nvm debug looks when I launch a new bash terminal:

nvm --version: v0.32.1
$SHELL: /bin/bash
$HOME: /Users/Rauliyohmc
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: none
which node: 
which iojs: 
which npm: 
npm config get prefix: -bash: npm: command not found
npm root -g: -bash: npm: command not found

And after I run nvm use --delete-prefix v6.9.2:

nvm --version: v0.32.1
$SHELL: /bin/bash
$HOME: /Users/Rauliyohmc
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v6.9.2
which node: $NVM_DIR/versions/node/v6.9.2/bin/node
which iojs: 
which npm: $NVM_DIR/versions/node/v6.9.2/bin/npm
npm config get prefix: /Users/rauliyohmc/.nvm/versions/node/v6.9.2
npm root -g: /Users/rauliyohmc/.nvm/versions/node/v6.9.2/lib/node_modules

@ljharb
Copy link
Member

ljharb commented Dec 19, 2016

@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?

@rgommezz
Copy link

That was it @ljharb, thanks a lot 🤖

@13protons
Copy link

13protons commented Dec 25, 2016

I was having the same issue trying to 'purify' my node versions, since I had noticed my 'system' version was pretty old (0.10.x). After uninstalling all version, reinstalling nvm and using it to install now, I was getting the prefix errors.

Doesn't get to the root of the issue, but a fix that worked for me was to install node from the package at nodejs.org. The prefix error goes away for me if nvm ls shows a 'system' version installed:

$ nvm ls
         v7.3.0
->       system
default -> system
node -> stable (-> v7.3.0) (default)
stable -> 7.3 (-> v7.3.0) (default)
iojs -> N/A (default)
lts/* -> lts/boron (-> N/A)
lts/argon -> v4.7.0 (-> N/A)
lts/boron -> v6.9.2 (-> N/A)

@ljharb
Copy link
Member

ljharb commented Dec 25, 2016

@alanguir what's your nvm debug print out? You're saying if you uninstall your system version, the prefix error will go away?

@dantrevino
Copy link

My system is Ubuntu 16.04, zsh, oh-my-zsh, with zsh-nvm and npm plugins. Node is installed via umake.

I was getting this error. Deleted my $NVM_DIR, exited my terminal, restarted it, and let the zsh-nvm plugin re-add it (from this repo). Now no error. Now instead of sad and confused, I'm happy and confused.

@adim86
Copy link

adim86 commented Jul 7, 2017

Im getting this error after following the same process @rauliyohmc did about removing the prefix

This is my nvm debug

nvm --version: v0.33.2
$SHELL: /bin/bash
$HOME: /root
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 4.2.37(1)-release (i686-pc-linux-gnu)'
uname -a: 'Linux 4.9.15-x86_64-linode81 #1 SMP Fri Mar 17 09:47:36 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux'
OS version: Ubuntu 12.10
curl: /usr/bin/curl, curl 7.27.0 (i686-pc-linux-gnu) libcurl/7.27.0 OpenSSL/1.0.1c zlib/1.2.7 libidn/1.25 librtmp/2.3
wget: /usr/bin/wget, GNU Wget 1.13.4 built on linux-gnu.
git: /usr/bin/git, git version 1.7.10.4
nvm current: system
which node: /usr/local/bin/node
which iojs:
which npm: /usr/local/bin/npm
npm config get prefix: /usr/bin/env: node: No such file or directory
npm root -g: /usr/bin/env: node: No such file or directory

@ljharb
Copy link
Member

ljharb commented Jul 8, 2017

@adim86 any chance that you're using a symlink for $HOME or $NVM_DIR, or that you have a case-insensitive filesystem?

@adim86
Copy link

adim86 commented Jul 8, 2017 via email

@ljharb
Copy link
Member

ljharb commented Jul 9, 2017

case-sensitive should be fine. if it's case-insensitive, ensure that the casing of $HOME and $NVM_DIR and whoami all are consistent.

@chrisspiegl
Copy link

chrisspiegl commented Nov 15, 2017

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 👍 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs followup We need some info or action from whoever filed this issue/PR.
Projects
None yet
Development

No branches or pull requests

9 participants