0

I installed nodejs on my ubuntu system. The command which nodejsgives me the following response: /usr/bin/nodejs which is correct because a nodejs -v gives me the version I installed, 0.10.25.

If I type which node instead, I get /usr/sbin/node which does nothing at all.

My question is now: How do I change the command node to /usr/sbin/nodejs so that I have a working installation for all the programs which rely on the command node?

Short: How do I execute /usr/bin/nodejs if I run node from the console?

Thanks in advance, F

2 Answers 2

2

In your .bashrc file, create an alias thus:

alias nodejs='/usr/bin/nodejs'

Don't add whitespaces otherwise they'll be counted. Another solution is to consider adding /usr/bin to your PATH. Know that /usr/sbin is parsed first, before /usr/bin/ but it's not wise to swap round these two locations because in the event duplicate commands are available (as in your case) it can lead to unknown behaviour. So creating an alias is a safer solution.

EDIT: To bring your .bashrc file changes into effect, execute:

source .bashrc

1
  • Thanks, I will accept this answer because I think it's very important mentioning the side effects and I like the solution with the alias.
    – Freddy
    Dec 13, 2015 at 22:56
1

Check your PATH variable

echo $PATH

Make sure /usr/bin is in front of /usr/sbin/

i.e. export PATH=/usr/bin:$PATH

1
  • 1
    PATH is one of the most commonly used environment variables. Usually people customize it in ~/.bashrc, so you don't have to specify it every time.
    – Patrick
    Dec 13, 2015 at 22:46

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.