Skip to content

Nodejs安装

yangyp8110 edited this page Jan 17, 2018 · 1 revision

下载

[root@yyp nodejs]# https://nodejs.org/dist/v6.9.5/node-v6.9.5.tar.gz

解压缩

[root@yyp nodejs]# tar -zxvf node-v6.9.5.tar.gz
[root@yyp nodejs]# ll
total 25768
drwxr-xr-x. 9  502 games     4096 Jan 31 16:29 node-v6.9.5
-rw-r--r--. 1 root root  26381690 Feb 19 06:26 node-v6.9.5.tar.gz
[root@yyp nodejs]# 
[root@yyp nodejs]# cd node-v6.9.5/
[root@yyp node-v6.9.5]# ./configure --prefix=/usr/local/install/nodejs/
WARNING: failed to autodetect C++ compiler version (CXX=g++)
WARNING: failed to autodetect C compiler version (CC=gcc)
Node.js configure error: No acceptable C compiler found!

        Please make sure you have a C compiler installed on your system and/or
        consider adjusting the CC environment variable if you installed
        it in a non-standard prefix.
        
[root@yyp node-v6.9.5]# 

编译环境安装

WARNING: failed to autodetect C++ compiler version (CXX=g++)

[root@yyp node-v6.9.5]# sudo yum install gcc-c++

继续编译 & 安装nodejs

[root@yyp node-v6.9.5]# ./configure --prefix=/usr/local//usr/local/install/nodejs/
[root@yyp node-v6.9.5]# make
等了十来分钟……

[root@yyp node-v6.9.5]# make install

配置环境变量

[root@yyp node-v6.9.5]# vi /etc/profile

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

[root@yyp node-v6.9.5]# source /etc/profile
[root@yyp node-v6.9.5]# node -v
v6.9.5
[root@yyp node-v6.9.5]# 

安装成功。

npm升级

[root@yyp node-v6.9.5]# npm -v
3.10.10
[root@yyp node-v6.9.5]# npm install npm -g
[esuser@yyp elasticsearch-head-master]$ npm -v
4.2.0

使用npm安装grunt:

[root@yyp ~]# npm install -g grunt-cli

……

[root@yyp ~]# grunt
grunt-cli: The grunt command line interface (v1.2.0)

Fatal error: Unable to find local grunt.

If you're seeing this message, grunt hasn't been installed locally to
your project. For more information about installing and configuring grunt,
please see the Getting Started guide:

http://gruntjs.com/getting-started
[root@yyp ~]# 

Clone this wiki locally