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:

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

    • avatar get the facts

      Wow! This could be one particular of the most useful blogs We’ve ever arrive across on this subject. Basically Excellent. I’m also an expert in this topic therefore I can understand your hard work.

      • avatar chilli casino bonus

        This actually answered my downside, thanks!

        • avatar best cat food wet

          When I originally commented I clicked the -Notify me when new comments are added- checkbox and now each time a comment is added I get four emails with the same comment. Is there any way you can remove me from that service? Thanks!

          • avatar best site

            I was wondering if you ever thought of changing the layout of your site? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or 2 images. Maybe you could space it out better?