centos 使用 nvm 安装 nodejs (nvm安装时出错,git 版本太老)

安装 nvm

使用如下命令安装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 已经安装了 ,可是要更新 gitYour 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

图片描述

安装 nodejs

查看都有哪些版本能够安装:

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 查看帮助。

图片描述

相关文章
相关标签/搜索