1

I had previously installed node through the tools found on their website and it was giving me a warning regarding Unbrewed header files and listing a bunch of references to files within /node/ directories when running brew doctor.

Previous to the uninstall, I was getting the following versions of node and npm:

$ node -v
v11.13.0
~
$ npm -v
6.11.3

I attempted to uninstall the existing node install by following the instructions found here: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)

I then tried to reinstall node by running brew install node and everything went through successfully, however, when checking my node and npm versions, I am still getting a readout of the old versions referenced above. Attempting to run a brew upgrade

$ brew upgrade node
Warning: node 13.3.0 already installed
~
$ node -v
v11.13.0
~
$ npm -v
6.11.3

Could I have missed some files when uninstalling the previous version of node? Is there somewhere I am not looking?

1 Answers1

3

First check where your node is installed by doing

$ which node

If you have a path something like /usr/local/bin/node try reinstalling node.

If you have a path something like ~/.nvm/versions/node/v11.13.0/bin/node then your are running your node from nvm.

If that is the case, check if your ~/.bashrc or your ~/.zshrc depending on your terminal, and confirm if there are any commands that looks something like 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

Remove these lines, and run the following command depending on your terminal.

$ source ~/.bashrc
$ source ~/.zshrc

Then check your node version again. Hopefully that solves your problem.

Wesgur
  • 3,140
  • 3
  • 18
  • 28
  • After running `which node` the following was returned: ```/Users/Matt/.nvm/versions/node/v11.13.0/bin/node``` I was not able to locate a `~/.bashrc` file but found a `~/.bash_profile` file that contains the lines that you outlined. I attempted removing them and running `$ source ~/.bash_profile` but that returned `-bash: bash_completion: command not found` – Matthew Nelson Dec 13 '19 at 03:52
  • Sure! It is too long for one comment so I will divide it into two ``` # Add `~/bin` to the `$PATH` export PATH="$HOME/bin:$PATH"; # Load the shell dotfiles, and then some: # * ~/.path can be used to extend `$PATH`. # * ~/.extra can be used for other settings you don’t want to commit. for file in ~/.{path,bash_prompt,exports,aliases,functions,extra}; do [ -r "$file" ] && [ -f "$file" ] && source "$file"; done; unset file; ``` – Matthew Nelson Dec 13 '19 at 17:10
  • 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 export PATH="/usr/local/sbin:$PATH" – Matthew Nelson Dec 13 '19 at 17:11
  • Remove this section and try `source` again. `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` – Wesgur Dec 13 '19 at 20:03
  • I removed those lines and ran: `$ source ~/.bash_profile` `$ node -v v11.13.0 ~ $ npm -v 6.11.3 ~ ` it looks like the node and npm versions are still the same – Matthew Nelson Dec 13 '19 at 21:19
  • Can you restart your terminal? and try it again? If it doesn't change, can you confirm if `which node` changed? – Wesgur Dec 13 '19 at 21:22