在 Github 上獲取 Node.js 源碼
sudo git clone https://github.com/nodejs/node.git
修改目錄權(quán)限
sudo chmod -R 755 node
進入node目錄
cd node
使用 ./configure 創(chuàng)建編譯文件
sudo ./configure
如果報了以下錯誤
No acceptable C compiler found!
表示沒有c編譯環(huán)境网严,需要安裝c編譯環(huán)境
sudo apt-get install gcc
sudo apt-get install build-essential
編譯(這里花的時間賊長晚岭,很長的長)
sudo make
安裝(這個也需要很長時間)
sudo make install
node有一個模塊n州袒,用于管理node版本
sudo npm install -g n
升級到最新穩(wěn)定版
sudo n stable
升級npm
sudo npm install npm -g