CentOS安装Node.js

  • A+
所属分类:运维教程

你需要在https://nodejs.org/en/download/下载最新Nodejs版本,本文以v6.11.1为例:

  1. cd /usr/local/src/
  2. https://nodejs.org/dist/v6.11.1/node-v6.11.1.tar.gz

解压源码:

  1. tar -zxf node-v6.11.1.tar.gz

编译安装:

  1. cd node-v6.11.1
  2. ./configure --prefix=/usr/local/node/6.11.1
  3. make
  4. make install

配置NODE_HOME进入profile编辑环境变量:

  1. vi /etc/profile

设置nodejs的环境变量,在export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL一行上面添加如下内容:

  1. #set for nodejs
  2. export NODE_HOME=/usr/local/node/6.11.1
  3. export PATH=$NODE_HOME/bin:$PATH

:wq保存并退出,编译/etc/profile使配置生效:

  1. source /etc/profile

验证是否安装配置成功:

  1. node -v

如输出v6.11.1表示配置成功。

npm模块安装路径/usr/local/node/0.10.24/lib/node_modules/

Nodejs的官网提供了编译好的Linux二进制包,你也可以下载下来直接应用。

  • 问答中心
  • 微信小程序扫一扫
  • weinxin
  • 微信公众
  • 微信公众号扫一扫
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:49   其中:访客  49   博主  0

    • avatar web hosting providers

      Hey! I know this is kind of off topic but I was wondering which blog platform are you using for this site?
      I’m getting tired of Wordpress because I’ve had issues with
      hackers and I’m looking at options for another platform.
      I would be awesome if you could point me in the direction of a good platform.

      • avatar best web hosting 2020

        Hello there! Do you use Twitter? I’d like to follow you if that would be ok.
        I’m absolutely enjoying your blog and look forward
        to new updates.

        • avatar web host

          Hey there! I know this is kinda off topic but I’d figured
          I’d ask. Would you be interested in exchanging links or maybe guest writing a blog article
          or vice-versa? My website covers a lot of the
          same topics as yours and I believe we could greatly benefit from each other.
          If you might be interested feel free to shoot me an e-mail.

          I look forward to hearing from you! Great blog by the way!

          • avatar web hosting companies

            Thank you, I’ve recently been looking for information about this subject for ages and yours is the greatest I’ve came upon so far.
            But, what about the bottom line? Are you certain in regards
            to the source?

            • avatar Senaida Frodsham

              Kill Thousands Of Mosquitoes, Protect Family From Nasty Bites!

              For so many years, Mosquitoes and harmful bugs have caused us a lot of pain which leads to sickness, painful itching and lastly death.
              Thanks to this amazing device, you can easily put an end to this terrible insects and live happily without any mosquito worries.
              See This Device: https://zeep.ly/TjVGR

              • avatar grolyrtolemcs

                Unquestionably believe that which you stated. Your favorite reason seemed to be on the net the easiest thing to be aware of. I say to you, I definitely get annoyed while people consider worries that they just don’t know about. You managed to hit the nail upon the top as well as defined out the whole thing without having side effect , people could take a signal. Will likely be back to get more. Thanks

                • avatar website hosting

                  Hey! Would you mind if I share your blog with my zynga group?
                  There’s a lot of folks that I think would really appreciate your content.
                  Please let me know. Thank you

                  • avatar web hosting companies

                    This is really interesting, You are a very skilled blogger.
                    I have joined your feed and look forward to seeking more of your excellent post.
                    Also, I have shared your web site in my social networks!

                    • avatar web hosting services

                      Good day I am so happy I found your site, I really found you by
                      accident, while I was researching on Askjeeve for something
                      else, Nonetheless I am here now and would just like to say thank
                      you for a incredible post and a all round entertaining blog (I
                      also love the theme/design), I don’t have time to browse it all at
                      the minute but I have bookmarked it and also included your RSS feeds,
                      so when I have time I will be back to read a lot more, Please
                      do keep up the fantastic job.