使用如下命令安裝nvm
,結果出錯node
wget -qO- https://raw.githubusercontent.com/cnpm/nvm/master/install.sh | bash
以下:git
➜ ~ wget -qO- https://raw.githubusercontent.com/cnpm/nvm/master/install.sh | bash => Downloading nvm from git to '/root/.nvm' => Initialized empty Git repository in /root/.nvm/.git/ remote: Counting objects: 3928, done. remote: Total 3928 (delta 0), reused 0 (delta 0), pack-reused 3928 Receiving objects: 100% (3928/3928), 967.69 KiB | 210 KiB/s, done. Resolving deltas: 100% (2299/2299), done. error: pathspec 'v0.26.1' did not match any file(s) known to git.
他說錯誤,也看不出來什麼錯誤,換了一種方式,使用下面的命令安裝github
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
這時也報錯了,以下:shell
➜ ~ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 7731 100 7731 0 0 4345 0 0:00:01 0:00:01 --:--:-- 5888 => nvm is already installed in /root/.nvm, trying to update using git => error: pathspec 'v0.29.0' did not match any file(s) known to git. Your version of git is out of date. Please update it! => Appending source string to /root/.zshrc => Close and reopen your terminal to start using nvm
不過他說 nvm
已經安裝了 ,可是要更新 git
, Your version of git is out of date. Please update it!
npm
因而,看了如下 centos 系統裏的 git 版本segmentfault
➜ ~ git --version git version 1.7.1
確實太老了,如今都 2.10 了,因而在 centos 6.7 上安裝 git 的新版本了。centos
centos 系統中安裝最新版 git ,請看個人另一篇博文 《centos 6.7 安裝 最新版 git》bash
nvm
安裝完成後,可能要重啓一下 shell
纔有 nvm
這個命令。curl
重啓 shell
,輸入 nvm --version
能夠查看當前 nvm 的版本,以下:url
查看都有哪些版本能夠安裝:
nvm ls-remote
能夠看到當前最新版本是 v6.7.0 ,運行下面的命令來安裝:
nvm install v4.6.0 #我安裝的是 v4.6.0
查看安裝的版本
node --version
➜ ~ nvm install v4.6.0 ######################################################################## 100.0% WARNING: checksums are currently disabled for node.js v4.0 and later Now using node v4.6.0 (npm v2.15.9) ➜ ~ node --version v4.6.0 ➜ ~
查看一下當前已經安裝的版本
nvm ls
切換版本
nvm use v4.6.0
設置默認版本
nvm alias default v4.6.0
nvm 使用很簡單 ,詳細內容請使用 nvm help
查看幫助。