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 uses system node instead of default #1184

Closed
andre487 opened this issue Jul 31, 2016 · 30 comments
Closed

Nvm uses system node instead of default #1184

andre487 opened this issue Jul 31, 2016 · 30 comments
Labels
non-issue / invalid This isn't relevant to nvm, or turned out to be something unrelated. shell: zsh

Comments

@andre487
Copy link

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.

@ljharb
Copy link
Member

ljharb commented Jul 31, 2016

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?

@ljharb ljharb added shell: zsh needs followup We need some info or action from whoever filed this issue/PR. labels Jul 31, 2016
@andre487
Copy link
Author

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

@ljharb
Copy link
Member

ljharb commented Aug 2, 2016

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

@ljharb
Copy link
Member

ljharb commented Aug 2, 2016

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

@andre487
Copy link
Author

andre487 commented Aug 2, 2016

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

@andre487 andre487 closed this as completed Aug 2, 2016
@ljharb ljharb added non-issue / invalid This isn't relevant to nvm, or turned out to be something unrelated. and removed needs followup We need some info or action from whoever filed this issue/PR. labels Aug 2, 2016
@ambroselittle
Copy link

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.

@ljharb
Copy link
Member

ljharb commented Oct 18, 2018

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.

@ambroselittle
Copy link

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.

@mokolodi1
Copy link

For those who installed node with brew: brew uninstall node

@eng618
Copy link

eng618 commented Feb 5, 2019

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.

@ljharb
Copy link
Member

ljharb commented Feb 5, 2019

That’s because homebrew recently broke yarn users by removing “without node” as an option.

@jerrygreen
Copy link

Looks like it's still a problem

@ljharb
Copy link
Member

ljharb commented Jun 19, 2019

@jerrygreen please file a new issue.

@monotv
Copy link

monotv commented Aug 19, 2019

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

@jmnyarega
Copy link

jmnyarega commented Nov 28, 2019

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.

@isholaomotayo
Copy link

isholaomotayo commented Dec 20, 2019

@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

@xmihal03
Copy link

xmihal03 commented Sep 29, 2020

manual removing by rm /usr/local/bin/node worked for me, nvm system disappeared after that 🎉

@scottclayton
Copy link

@xmihal03
Oh wow… that's something I've been grappling with for an embarrassing number of years on this particular machine. Thanks a tonne!

@pierpeople
Copy link

anything - anything at all - modifying $PATH in any of your profile files, specifically after the line that sources nvm?

Thanks. In my case, I had nvs installed at some stage. Remove those lines fixed the issue.

@gvko
Copy link

gvko commented Jun 23, 2021

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

That fixed it for me. I had a bunch of export PATH="..." statements in my ~/.zshrc profile file after the statement that loads nvm. I just put the statements that source nvm after any other export PATH=... statement and it fixed it!

@matthew-kaye
Copy link

For me it was asdf that was the problem, so you can just unlink from there, or depending on how desperate you are, uninstall asdf. Run which node to see where your version is coming from

@hunterdeng500
Copy link

hunterdeng500 commented Nov 18, 2022

rm /usr/local/bin/node worked for me, too
system disappered when I type innvm current

@rapritchard
Copy link

@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 worked for me, I had $PATH modified in ~/.zshrc whilst using ~/.zprofile for nvm.

@michaelKaefer
Copy link

michaelKaefer commented Feb 3, 2023

For Linux users: if you installed nodejs with apt delete it with:

sudo apt purge nodejs
sudo apt autoremove nodejs

Open a new terminal and nvm will work as expected.

@nairu777
Copy link

nairu777 commented Feb 17, 2023

For Linux users: if you installed nodejs with apt delete it with:

sudo apt purge nodejs
sudo apt autoremove nodejs

Open a new terminal and nvm will work as expected.

I had the same problem on mac and used the brew equivalent:

brew uninstall node
nvm use <versionNr>

After removing "system" is not listed when using "nvm list". For me the problem started because I used "brew update && brew upgrade" for all my packages and this conflicted for NVM

@dsteinel
Copy link

First you need to check which node is active with which node (for me it was /usr/local/opt/node@16/bin/node) and the path which you see as an output is the path which you can remove with sudo rm /usr/local/opt/node@16/bin/node

@MrUltimate
Copy link

First you need to check which node is active with which node (for me it was /usr/local/opt/node@16/bin/node) and the path which you see as an output is the path which you can remove with sudo rm /usr/local/opt/node@16/bin/node

This seems to work for me temporarily. As soon as I restart my CLI, nvm reverts to using system. Any ideas what's happening? When I run which node the path returned is /Users/MrUltimate/.nodenv/shims/node

If I rm -rf that path nvm current switches to none and then I can set my preferred version. But this resets every time I restart my CLI. Anyone have any ideas?

@ljharb
Copy link
Member

ljharb commented Dec 21, 2023

@MrUltimate i assume nodenv is something you have installed that’s interfering. You could try removing it?

@MrUltimate
Copy link

@MrUltimate i assume nodenv is something you have installed that’s interfering. You could try removing it?

Yes, thanks. I did end up removing it and then setting both my default and stable alias so that nvm would default to my preferred version. Without that it would always default to none.

@ljharb
Copy link
Member

ljharb commented Dec 21, 2023

stable is a built-in one, you should just need nvm alias default node, but if your nvm is up to date, the first node install should be setting that alias.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
non-issue / invalid This isn't relevant to nvm, or turned out to be something unrelated. shell: zsh
Projects
None yet
Development

No branches or pull requests