Nvm: Nvm uses system node instead of default

Created on 31 Jul 2016  Ā·  17Comments  Ā·  Source: nvm-sh/nvm

OSX 10.11.6, zsh 5.2

I have this nvm settings:

āžœ  ~ nvm ls
         v4.4.7
->       system
default -> v4.4.7
node -> stable (-> v4.4.7) (default)
stable -> 4.4 (-> v4.4.7) (default)
iojs -> N/A (default)
lts/* -> lts/argon (-> v4.4.7)
lts/argon -> v4.4.7

This listing is from new terminal's tab. And by default nvm uses not default version but the system.

non-issue / invalid zsh

Most helpful comment

@andre487 also, do you have anything - anything at all - modifying $PATH in any of your profile files, specifically _after_ the line that sources nvm?

All 17 comments

Do you have a ~/.nvmrc file? Can you locate your profile file where nvm.sh is sourced, and see if it's using --no-use? What does nvm debug print out?

No, I don't have ~/.nvmrc.

nvm.sh call in my .zshrc looks this way:

export NVM_DIR="$HOME/.nvm"
if [[ -s "$NVM_DIR/nvm.sh" ]]; then
    source "$NVM_DIR/nvm.sh"
fi

There is the nvm debug result:

āžœ  ~ nvm debug
nvm --version: v0.31.3
$SHELL: /bin/zsh
$HOME: /Users/andre487
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: system
which node: /usr/local/bin/node
which iojs: iojs not found
which npm: /usr/local/bin/npm
npm config get prefix: /usr/local
npm root -g: /usr/local/lib/node_modules

@andre487 ok so when you run:

nvm use node
nvm current
nvm ls
nvm use system
nvm current
nvm deactivate
node --version

what's the output you get?

@andre487 also, do you have anything - anything at all - modifying $PATH in any of your profile files, specifically _after_ the line that sources nvm?

@ljharb Yes, that's it. I had a source of extra exports after nvm and when I swaped them, version of Node became correct.

Thank you!

In my case, "system" node was installed inadvertently by installing yarn via MacPorts. It seems that port install isn't smart enough to look for nvm node, so it installed a copy in opt/local/.

And in my .zshrc, it was prepending the path to there before calling nvm.sh. If I removed that prepending, it worked, but of course I want MacPorts to work so that's not an option.

Interestingly, nvm uninstall system didn't work. I had to manually by:

sudo rm -f /opt/local/bin/node
sudo rm -rf /opt/loca/include/node

Then restart CLI, of course. No more warnings, and it doesn't see a "system" version installed.

nvm can’t uninstall something it didn’t install; you’d have to use macports to do that, or do it manually as you indicated.

Sure. I came across something that suggested using nvm uninstall system. I didn't even know it could install system, so I was wondering if it had smarts around finding/removing.

Anyhow, also noting that sudo port uninstall node didn't work, either. Presumably because it was installed as a dependency of yarn.. And port uninstall yarn didn't remove it. So it seemed manual was the only option in my case.

For those who installed node with brew: brew uninstall node

Yes, even though I installed yarn with brew via brew install yarn --without-node it still installed node for some reason... So had to run brew uninstall node --ignore-dependencies to uninstall that node version and all is well again.

That’s because homebrew recently broke yarn users by removing ā€œwithout nodeā€ as an option.

Looks like it's still a problem

@JerryGreen please file a new issue.

@andre487 also, do you have anything - anything at all - modifying $PATH in any of your profile files, specifically _after_ the line that sources nvm?

This fixed it for me.

If none of the above solutions works for you, here are the steps I followed:

  • remove system node sudo rm /usr/local/bin/node, this should be your option if commands like brew uninstall is not working.

    • set your default version in .nvmrc echo "8.11.3" > .nvmrc

    • follow these steps to configure your bash configure your bash

    • restart your cli

NOTE: It is advised to uninstall node before making use of nvm.

@andre487 also, do you have anything - anything at all - modifying $PATH in any of your profile files, specifically _after_ the line that sources nvm?

This fixed it for me.

Worked for me too

best to move this

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

down to the bottom of ~/.zshrc or ~/.bash_profile

manual removing by rm /usr/local/bin/node worked for me, nvm system disappeared after that šŸŽ‰

Was this page helpful?
0 / 5 - 0 ratings