2

I installed nvm on my Mac using Homebrew.

brew update
brew install nvm
mkdir ~/.nvm
nano ~/.bash_profile

Added below to my .bash_profile

export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh

Then in my shell

source ~/.bash_profile
echo $NVM_DIR

After doing those steps I installed nodejs using nvm

nvm install v6.11.2

The problem is when I type node it says node: command not found

$ node
$ -bash: node: command not found

How do I make nodejs to work?

Below is my .bash_profile

if [ -f `brew --prefix`/etc/bash_completion ]; then
    . `brew --prefix`/etc/bash_completion
fi
export PATH="/usr/local/bin:$PATH"

#for brew nvm
exportNVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh

This is the list of nodejs according to nvm

$ nvm list
        v6.11.2
node -> stable (-> v6.11.2) (default)
stable -> 6.11 (-> v6.11.2) (default)
iojs -> N/A (default)
lts/* -> lts/boron (-> v6.11.2)
lts/argon -> v4.8.4 (-> N/A)
lts/boron -> v6.11.2
3
  • 1
    Did you try with a new Terminal window? You can also try 'nvm use v6.11.2' after install. Nvm should add node to your path. Commented Aug 3, 2017 at 4:15
  • @Mikko This eventually led me to fixing my issue. I was running 'nvm use v6.11.2 on the terminal and it was not showing any error messages until I closed the terminal (as you have suggested) and ran the 'nvm use v6.11.2' command again. Then it eventually returned a suggestion to Run nvm use --delete-prefix v6.11.2 to unset the nvm from '/usr/local/Cellar/nvm/0.33.2/versions/node/v6.11.2' which eventually resolved my issue. You can post your comment as an answer and I will accept it as soon as you do. Thank you. Commented Aug 3, 2017 at 5:02
  • Glad to hear, I'll make an answer out of the comment, feel free to edit it if you think you can make it follow your solution better Commented Aug 3, 2017 at 5:13

1 Answer 1

7

Nvm should add node to your path. Close your terminal and open a new one. Try running node now. If you still have issues run:

nvm use v6.11.2

There seems to be an issue with nvm installations with homebrew. The fix is to run:

nvm use --delete-prefix v6.11.2 (or which ever version you are running)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.