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!)

19 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
  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
  14. Kanhasoft is the top-notch Node.js App development company in India. We have 45+ experienced programmers to delivered successful NodeJS Application development globally. Visit our site to know more about us.

    ReplyDelete
  15. Very Helpful and informative blog! Keep sharing such blogsSoftware Development Company in India

    ReplyDelete
  16. Expresstech Softwares is a leading node.js Development Company provider company. Hire Node.js developer from us who are expert in each development aspect. Contact us: +91-9806724185 or Contact@expresstechsoftwares.com

    ReplyDelete