Modifying $PATH variable

Viewed 60337

Trying to install node.js.

Did brew install node

It seems to have worked.

However, received this message upon its completion

Homebrew installed npm.
We recommend prepending the following path to your PATH environment
variable to have npm-installed binaries picked up:
/usr/local/share/npm/bin

Ok ... so, I open my bash_profile...

And this is what I have in it:

 export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"

 [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

Trying to understand how to modify it correctly so I won't ruin it ...

Do I add /usr/local/share/npm/bin like this

export PATH="/usr/local/bin:/usr/local/sbin:~/bin/usr/local/share/npm/bin:$PATH"

If not, what is the correct way to add that path?

Thank you for any help provided!

PS. let me know if there is any additional information I could have provided

EDIT

upon seeing which npm in macedigital's answer, I ran that ...

and got this: /usr/local/bin/npm

and that was before I did the second answer (ie, ThiefMaster's answer).

ran which npm again ...

and got the same answer as before ...

i did echo $PATH and got this:

/Users/name/.rvm/gems/ruby-1.9.3-p374/bin:/Users/name/.rvm/gems/ruby-1.9.3-p374@global/bin:/Users/name/.rvm/rubies/ruby-1.9.3-p374/bin:/Users/name/.rvm/bin:/usr/local/share/npm/bin:/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/local/git/bin

So, it looks like I already had it installed?

Therefore, how do I handle the answers? I hate leaving it unresolved since both of you were so helpful and I feel bad that I asked without providing echo $PATH information since that would have told you that I had it installed ...

EDIT 2

ls -la /usr/local/share/npm/bin gets this:

ls: /usr/local/share/npm/bin: No such file or directory

which -a npm gets this: /usr/local/bin/npm

EDIT 3

ls -a /usr/local/bin/npm gets this: /usr/local/bin/npm

there's no timestamp...

3 Answers

In PATH ORDER IS IMPORTANT. So anything before desired npm version will still cause problems.

#adding in first place of the path, before anything else
export PATH=/usr/local/bin:otherPathEntries:$PATH

assuming that version of npm You want is in /usr/local/bin, to check all use 'which -a npm'

Related