Ubuntu 14.04安裝Nodejs 4.x版本

Ubuntu 14.04自帶的node是0.10.x的,想安裝4.x的版本,網(wǎng)上查了一下,有的說編譯源代碼什么的,太麻煩。既然有編譯好的版本,完全沒必要自己編譯??!這里就有各個(gè)發(fā)布版及其安裝辦法,照著方法安裝一下就好了。

wget -qO- https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
node -v
npm -v

但是現(xiàn)實(shí)情況中并不是這么順利的,中途還會(huì)出現(xiàn)各種問題。。。以下記錄幾個(gè)遇到的問題。

apt-get update 時(shí)簽名無法驗(yàn)證的問題

錯(cuò)誤信息:

“the following signatures couldn’t be verified because the public key is not available”

解決方法看這里。

apt-get update 時(shí)404的問題

錯(cuò)誤信息:

Err http://security.ubuntu.com raring-security/main amd64 Packages 404  Not Found [IP: 91.189.91.15 80]

有的地方說,要把/etc/apt/sources.list這個(gè)文件中的archive.ubuntu.com 和security.ubuntu.com這兩個(gè)網(wǎng)址換成old-releases.ubuntu.com。但是我換了之后,發(fā)現(xiàn)連IP地址都找不到了。不太清楚是什么原因。

還會(huì)跑出來“Hash sum mismatch”這個(gè)錯(cuò)誤。這個(gè)方法也試了,不過沒有什么作用:

sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update

沒有什么好辦法,直接換國(guó)內(nèi)的源算了,比如阿里云的源。

Ubuntu 14.04 更換阿里云的源

修改apt源文件

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #備份
sudo vim /etc/apt/sources.list #修改,然后把下面的阿里云源地址粘貼進(jìn)去
sudo apt-get update #更新列表

阿里云源地址

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

參考

https://www.yurendu.com/code/16.html
http://askubuntu.com/questions/672994/how-to-install-nodejs-4-using-apt
https://github.com/nodesource/distributions
https://chrisjean.com/fix-apt-get-update-the-following-signatures-couldnt-be-verified-because-the-public-key-is-not-available/
http://askubuntu.com/questions/553765/failed-to-fetch-update-on-ubuntu-14-04-lts-trusty-tahr

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容