Ubuntu 14.04自帶的node是0.10.x的魔熏,想安裝4.x的版本,網(wǎng)上查了一下啼止,有的說編譯源代碼什么的道逗,太麻煩。既然有編譯好的版本献烦,完全沒必要自己編譯白仪稀!這里就有各個發(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)實情況中并不是這么順利的,中途還會出現(xiàn)各種問題即横。噪生。。以下記錄幾個遇到的問題东囚。
apt-get update 時簽名無法驗證的問題
錯誤信息:
“the following signatures couldn’t be verified because the public key is not available”
解決方法看這里跺嗽。
apt-get update 時404的問題
錯誤信息:
Err http://security.ubuntu.com raring-security/main amd64 Packages 404 Not Found [IP: 91.189.91.15 80]
有的地方說,要把/etc/apt/sources.list這個文件中的archive.ubuntu.com 和security.ubuntu.com這兩個網(wǎng)址換成old-releases.ubuntu.com页藻。但是我換了之后桨嫁,發(fā)現(xiàn)連IP地址都找不到了。不太清楚是什么原因份帐。
還會跑出來“Hash sum mismatch”這個錯誤璃吧。這個方法也試了,不過沒有什么作用:
sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update
沒有什么好辦法废境,直接換國內(nèi)的源算了畜挨,比如阿里云的源筒繁。
Ubuntu 14.04 更換阿里云的源
修改apt源文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #備份
sudo vim /etc/apt/sources.list #修改,然后把下面的阿里云源地址粘貼進去
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