Wednesday, March 27, 2013

How to Install NodeJS on CentOS


NodeJS is currently not part of the CentOS standard repo's

Give it a try:

# yum install nodejs
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cat.pdx.edu
 * extras: mirrors.cat.pdx.edu
 * updates: mirrors.cat.pdx.edu
Setting up Install Process
No package nodejs available.
Error: Nothing to do



Solution

Install NodeJS from sources.


Install Dependencies


# yum install openssl-devel
# yum install gcc-c++
-- OR -- 
# yum groupinstall 'Development Tools'


Install NodeJS

# mkdir ~/sources
# cd ~/sources
# wget http://nodejs.org/dist/node-latest.tar.gz
# tar zxvf node-latest.tar.gz
# cd node-v<TAB>
# ./configure
# make
# make install
# mv /root/sources/node-v0.10.1/out/Release /opt/node-v0.10.1
# ln -s /opt/node-v0.10.1/node /usr/bin/node

NOTE:  When you cd to the newly created directory, type "cd node-v" and then hit your TAB key for tab completion.  The full directory name will be something like /root/sources/node-v0.10.1


Test NodeJS

# node
v0.10.1

Sponsor Ads(Please visit one if you liked this article. Thanks!)

16 comments:

  1. Thank you! This was really useful for me, the first google link has an expired URL for the "wget" node command, but after filtering out old results, I came across this, thank you again!

    ReplyDelete
  2. Thank you so much, its very useful and easy to understand. just one detail if you want to show the version. (node -v)

    ReplyDelete
    Replies
    1. thanks for this tip!!!!

      Delete
  3. Very simple!! that is good post, thanks

    ReplyDelete
  4. how to install lex and yacc in centos? can u plz help me?

    ReplyDelete
  5. I tried to follow but had one error (centos 6.4 - 26JULY)
    [root@ip-10-179-7-27 sources]# wget http://nodejs.org/dist/node-latest.tar.gz
    -bash: wget: command not found

    -> yum install wget fix it ;)

    hope it helps

    ReplyDelete
  6. More simple use epel repository

    yum install nodejs

    Done!

    ReplyDelete
  7. I agree with Anonymous! I always opt to use yum to install packages. It helps with the management down the road, too. At the time I wrote this article, I don't think an epel repo for nodejs existed. It obviously does now. So, my instructions are now deprecated. Thank you, Anonymous!

    ReplyDelete
  8. the version installed by yum is very old.

    ReplyDelete
  9. Thank you very useful, simple and easy

    ReplyDelete
  10. Very fine!
    I tried to install it with epel on Centos7 but got a bunch of errors.

    ReplyDelete
  11. Thanks Lex! This is good instruction! I only received the bunch of errors with make command.

    ReplyDelete
  12. Thanks Lex! This is good instruction! I only received the bunch of errors with make command.

    ReplyDelete
  13. Thank you for sharing this information. This article is very interesting and useful. Keep up the good work!

    ReplyDelete