1、配置Ubuntu軟件更新源
一、備份原有的源列表node
sudo cp /etc/apt/sources.list /etc/apt/sources.list.old
二、編輯source.list文件python
sudo vim /etc/apt/source.list
固然,你也能夠選擇gedit等工具編輯linux
sudo gedit /etc/apt/source.list
三、複製源至source.list中shell
好比阿里雲源:ubuntu
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial universe deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties deb http://archive.canonical.com/ubuntu xenial partner deb-src http://archive.canonical.com/ubuntu xenial partner deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
四、執行update命令vim
sudo apt-get update
2、安裝Nodejs環境centos
一、安裝依賴 工具
nodejs的一些模塊可能會依賴一些編譯工具,如c編譯器和python環境,wget命令用來從指定的URL下載文件。
apt-get是在各個平臺都有相關的包管理工具,好比ubuntu下面有apt-get,centos下面有yum,mac下面有brew等,你能夠直接使用apt-get安裝。阿里雲
apt-get install python gcc make g++ wget
二、安裝nodejs
在linux下默認源中沒有node的程序,因此不推薦使用apt-get安裝。推薦使用wget下載nodejs源碼安裝,nodejs個版本源碼列表:https://nodejs.org/download/rc/。rest
cd /home mkdir softwares cd softwares wget https://nodejs.org/download/rc/v9.0.0-rc.0/node-v9.0.0-rc.0.tar.gz tar -zxvf node-v9.0.0-rc.0.tar.gz cd node-v9.0.0-rc.0
解壓後的目錄下會有一個configure文件,是一個shell腳本,它能夠自動設定源程序以符合各類不一樣平臺上Unix系統的特性,而且根據系統叄數及環境產生合適的Makefile文件或是C的頭文件(header file),讓源程序能夠很方便地在這些不一樣的平臺上被編譯鏈接。
使用./configure 配置源碼:
./configure
使用make insatll進行安裝:
make insatll
或許等待過程很漫長,執行完畢之時node即安裝完成。