Ubuntu14.04安裝最新版nodejs

最近公司服務(wù)器因?yàn)槟承┰蚩呛浚瑢?dǎo)致服務(wù)器環(huán)境需要全部重新部署规求,安裝nodejs又忘了稿壁,記錄下实束,方便下次使用奥秆。

安裝最新版nodejs

更新ubuntu軟件源
sudo apt-get update
sudo apt-get install -y python-software-properties software-properties-common
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
安裝nodejs
sudo apt-get install nodejs
更新npm的包鏡像源,方便快速下載
sudo npm config set registry https://registry.npm.taobao.org
sudo npm config list
全局安裝n管理器(用于管理nodejs版本)
sudo npm install n -g
安裝最新的nodejs(stable版本)
sudo n stable
sudo node -v

QA

Q: 更新軟件源出現(xiàn)-找不到對應(yīng)的KEY
// error code
W: There is no public key available for the following key IDs:
8B48AD6246925553
W: Failed to fetch http://mirrors.aliyuncs.com/ubuntu/dists/precise/Release.gpg  Could not connect to mirrors.aliyuncs.com:80 (10.143.34.200), connection timed out

// A:resolve: add key
gpg --keyserver keyserver.ubuntu.com --recv-keys 8B48AD6246925553
gpg -a --export 8B48AD6246925553 | sudo apt-key add -

Q: aliyun咸灿、163等其他軟件源一直出現(xiàn)下載失敗

// error code
W: Failed to fetch http://mirrors.163.com/ubuntu/dists/precise/Release.gpg  Could not connect to mirrors.163.com:80 (123.58.173.106). - connect (111: Connection refused)
W: Failed to fetch http://mirrors.163.com/ubuntu/dists/precise-security/Release.gpg  Unable to connect to mirrors.163.com:http:
W: Failed to fetch http://mirrors.163.com/ubuntu/dists/precise-updates/Release.gpg  Unable to connect to mirrors.163.com:http:
W: Failed to fetch http://mirrors.163.com/ubuntu/dists/precise-proposed/Release.gpg  Unable to connect to mirrors.163.com:http:
W: Failed to fetch http://mirrors.163.com/ubuntu/dists/precise-backports/Release.gpg  Unable to connect to mirrors.163.com:http:
W: Some index files failed to download. They have been ignored, or old ones used instead.

// A: 部分網(wǎng)絡(luò)問題构订,下載失敗,嘗試換成官方源避矢,雖然比較慢悼瘾,但是能下載
// resolve:修改apt文件  /etc/apt/sources.list(注意備份)
# Ubuntu官方
deb http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse

Q: sudo make編譯nodejs失敗

make[1]: *** [/home/software/node-v7.8.0/out/Release/obj.target/v8_libplatform/deps/v8/src/libplatform/default-platform.o] Error 1
make[1]: Leaving directory `/home/software/node-v7.8.0/out'
make: *** [node] Error 2

// A: gcc版本太低囊榜,需要把gcc升級到4.8以上

ubuntu軟件源

修改/etc/apt/sources.list為以下軟件源(改前請備份)
163和里面在部分網(wǎng)絡(luò)下會一直下載失敗,可以改回官方源下載

源列表

http://wiki.ubuntu.org.cn/模板:14.04source

Ubuntu官方
deb http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
163軟件源
deb http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
aliyun軟件源
deb http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse

deb http://mirrors.aliyuncs.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ precise main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ precise-backports main restricted universe multiverse
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末亥宿,一起剝皮案震驚了整個濱河市卸勺,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌烫扼,老刑警劉巖曙求,帶你破解...
    沈念sama閱讀 207,113評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異映企,居然都是意外死亡悟狱,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,644評論 2 381
  • 文/潘曉璐 我一進(jìn)店門堰氓,熙熙樓的掌柜王于貴愁眉苦臉地迎上來挤渐,“玉大人,你說我怎么就攤上這事豆赏≌醴疲” “怎么了?”我有些...
    開封第一講書人閱讀 153,340評論 0 344
  • 文/不壞的土叔 我叫張陵掷邦,是天一觀的道長白胀。 經(jīng)常有香客問我,道長抚岗,這世上最難降的妖魔是什么或杠? 我笑而不...
    開封第一講書人閱讀 55,449評論 1 279
  • 正文 為了忘掉前任,我火速辦了婚禮宣蔚,結(jié)果婚禮上向抢,老公的妹妹穿的比我還像新娘。我一直安慰自己胚委,他們只是感情好挟鸠,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,445評論 5 374
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著亩冬,像睡著了一般艘希。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上硅急,一...
    開封第一講書人閱讀 49,166評論 1 284
  • 那天覆享,我揣著相機(jī)與錄音,去河邊找鬼营袜。 笑死撒顿,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的荚板。 我是一名探鬼主播凤壁,決...
    沈念sama閱讀 38,442評論 3 401
  • 文/蒼蘭香墨 我猛地睜開眼吩屹,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了拧抖?” 一聲冷哼從身側(cè)響起祟峦,我...
    開封第一講書人閱讀 37,105評論 0 261
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎徙鱼,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體针姿,經(jīng)...
    沈念sama閱讀 43,601評論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡袱吆,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,066評論 2 325
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了距淫。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片绞绒。...
    茶點(diǎn)故事閱讀 38,161評論 1 334
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖榕暇,靈堂內(nèi)的尸體忽然破棺而出蓬衡,到底是詐尸還是另有隱情,我是刑警寧澤彤枢,帶...
    沈念sama閱讀 33,792評論 4 323
  • 正文 年R本政府宣布狰晚,位于F島的核電站,受9級特大地震影響缴啡,放射性物質(zhì)發(fā)生泄漏壁晒。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,351評論 3 307
  • 文/蒙蒙 一业栅、第九天 我趴在偏房一處隱蔽的房頂上張望秒咐。 院中可真熱鬧,春花似錦碘裕、人聲如沸携取。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,352評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽雷滋。三九已至,卻和暖如春你弦,著一層夾襖步出監(jiān)牢的瞬間惊豺,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,584評論 1 261
  • 我被黑心中介騙來泰國打工禽作, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留尸昧,地道東北人。 一個月前我還...
    沈念sama閱讀 45,618評論 2 355
  • 正文 我出身青樓旷偿,卻偏偏與公主長得像烹俗,于是被迫代替她去往敵國和親爆侣。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,916評論 2 344

推薦閱讀更多精彩內(nèi)容