下载nvm包:

[root@centos ~]# wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
=> Downloading nvm as script to '/root/.nvm' => Appending nvm source string to /root/.bashrc
=> Appending bash_completion source string to /root/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now: export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

  上面提示相关的环境变量已经在配置文件/root/.bashrc中给我们自动添加好了,需要重新进入ssh。

  按它说的,重新进入ssh后,开始安装nodejs和npm:

[root@centos ~]# nvm ls-remote --lts
v4.2.0 (LTS: Argon)
v4.2.1 (LTS: Argon)
v4.2.2 (LTS: Argon)
v4.2.3 (LTS: Argon)
v4.2.4 (LTS: Argon)
v4.2.5 (LTS: Argon)
v4.2.6 (LTS: Argon)
v4.3.0 (LTS: Argon)
v4.3.1 (LTS: Argon)
v4.3.2 (LTS: Argon)
v4.4.0 (LTS: Argon)
v4.4.1 (LTS: Argon)
v4.4.2 (LTS: Argon)
v4.4.3 (LTS: Argon)
v4.4.4 (LTS: Argon)
v4.4.5 (LTS: Argon)
v4.4.6 (LTS: Argon)
v4.4.7 (LTS: Argon)
v4.5.0 (LTS: Argon)
v4.6.0 (LTS: Argon)
v4.6.1 (LTS: Argon)
v4.6.2 (LTS: Argon)
v4.7.0 (LTS: Argon)
v4.7.1 (LTS: Argon)
v4.7.2 (LTS: Argon)
v4.7.3 (LTS: Argon)
v4.8.0 (LTS: Argon)
v4.8.1 (LTS: Argon)
v4.8.2 (LTS: Argon)
v4.8.3 (LTS: Argon)
v4.8.4 (LTS: Argon)
v4.8.5 (LTS: Argon)
v4.8.6 (LTS: Argon)
v4.8.7 (LTS: Argon)
v4.9.0 (LTS: Argon)
v4.9.1 (Latest LTS: Argon)
v6.9.0 (LTS: Boron)
v6.9.1 (LTS: Boron)
v6.9.2 (LTS: Boron)
v6.9.3 (LTS: Boron)
v6.9.4 (LTS: Boron)
v6.9.5 (LTS: Boron)
v6.10.0 (LTS: Boron)
v6.10.1 (LTS: Boron)
v6.10.2 (LTS: Boron)
v6.10.3 (LTS: Boron)
v6.11.0 (LTS: Boron)
v6.11.1 (LTS: Boron)
v6.11.2 (LTS: Boron)
v6.11.3 (LTS: Boron)
v6.11.4 (LTS: Boron)
v6.11.5 (LTS: Boron)
v6.12.0 (LTS: Boron)
v6.12.1 (LTS: Boron)
v6.12.2 (LTS: Boron)
v6.12.3 (LTS: Boron)
v6.13.0 (LTS: Boron)
v6.13.1 (LTS: Boron)
v6.14.0 (LTS: Boron)
v6.14.1 (LTS: Boron)
v6.14.2 (LTS: Boron)
v6.14.3 (LTS: Boron)
v6.14.4 (LTS: Boron)
v6.15.0 (LTS: Boron)
v6.15.1 (LTS: Boron)
v6.16.0 (LTS: Boron)
v6.17.0 (LTS: Boron)
v6.17.1 (Latest LTS: Boron)
v8.9.0 (LTS: Carbon)
v8.9.1 (LTS: Carbon)
v8.9.2 (LTS: Carbon)
v8.9.3 (LTS: Carbon)
v8.9.4 (LTS: Carbon)
v8.10.0 (LTS: Carbon)
v8.11.0 (LTS: Carbon)
v8.11.1 (LTS: Carbon)
v8.11.2 (LTS: Carbon)
v8.11.3 (LTS: Carbon)
v8.11.4 (LTS: Carbon)
v8.12.0 (LTS: Carbon)
v8.13.0 (LTS: Carbon)
v8.14.0 (LTS: Carbon)
v8.14.1 (LTS: Carbon)
v8.15.0 (LTS: Carbon)
v8.15.1 (LTS: Carbon)
v8.16.0 (LTS: Carbon)
v8.16.1 (LTS: Carbon)
v8.16.2 (Latest LTS: Carbon)
v10.13.0 (LTS: Dubnium)
v10.14.0 (LTS: Dubnium)
v10.14.1 (LTS: Dubnium)
v10.14.2 (LTS: Dubnium)
v10.15.0 (LTS: Dubnium)
v10.15.1 (LTS: Dubnium)
v10.15.2 (LTS: Dubnium)
v10.15.3 (LTS: Dubnium)
v10.16.0 (LTS: Dubnium)
v10.16.1 (LTS: Dubnium)
v10.16.2 (LTS: Dubnium)
v10.16.3 (LTS: Dubnium)
v10.17.0 (Latest LTS: Dubnium)
v12.13.0 (Latest LTS: Erbium)

  挑最新版12.13.0安装,失败了:

[root@centos ~]# nvm install 12.13.
Downloading and installing node v12.13.0...
Downloading https://nodejs.org/dist/v12.13.0/node-v12.13.0-linux-x86.tar.xz... curl: () The requested URL returned error: Not Found
Binary download from https://nodejs.org/dist/v12.13.0/node-v12.13.0-linux-x86.tar.xz failed, trying source.
grep: /root/.nvm/.cache/bin/node-v12.13.0-linux-x86/node-v12.13.0-linux-x86.tar.xz: No such file or directory
Provided file to checksum does not exist.
Binary download failed, trying source.
Detected that you have CPU core(s)
Number of CPU core(s) less than or equal to , running in single-threaded mode
Downloading https://nodejs.org/dist/v12.13.0/node-v12.13.0.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
$>./configure --prefix=/root/.nvm/versions/node/v12.13.0 <
which: no python2. in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
Please use Python 2.7: /usr/bin/python2 ./configure --prefix=/root/.nvm/versions/node/v12.13.0
nvm: install v12.13.0 failed!

  提示说没有python2.7,确认下(默认会装2.6.6版本):

[root@centos ~]# yum list installed | grep python
abrt-addon-python.i686
abrt-python.i686 2.0.-.el6.centos @anaconda-CentOS-.i386/6.9
dbus-python.i686 0.83.-6.1.el6 @anaconda-CentOS-.i386/6.9
libproxy-python.i686 0.3.-.el6 @anaconda-CentOS-.i386/6.9
libreport-python.i686 2.0.-.el6.centos @anaconda-CentOS-.i386/6.9
libxml2-python.i686 2.7.-.el6_8. @anaconda-CentOS-.i386/6.9
newt-python.i686 0.52.-.el6 @anaconda-CentOS-.i386/6.9
python.i686 2.6.-.el6_8 @anaconda-CentOS-.i386/6.9
python-argparse.noarch
python-babel.noarch 0.9.-5.1.el6 @os
python-backports.i686 1.0-.el6 @os
python-backports-ssl_match_hostname.noarch
python-chardet.noarch 2.2.-.el6 @os
python-cheetah.i686 2.4.-.el6 @os
python-configobj.noarch
python-crypto2..i686 2.6.-.el6 @os
python-dmidecode.i686 3.10.-.el6 @anaconda-CentOS-.i386/6.9
python-iniparse.noarch
python-jinja2.i686 2.2.-.el6 @os
python-jsonpatch.noarch
python-jsonpointer.noarch
python-libs.i686 2.6.-.el6_8 @anaconda-CentOS-.i386/6.9
python-markdown.noarch
python-oauthlib.noarch
python-prettytable.noarch
python-pycurl.i686 7.19.-.el6 @anaconda-CentOS-.i386/6.9
python-pygments.noarch
python-requests.noarch
python-setuptools.noarch
python-six.noarch 1.9.-.el6 @os
python-urlgrabber.noarch
python-urllib3.noarch 1.10.-.el6 @os
rpm-python.i686 4.8.-.el6 @anaconda-CentOS-.i386/6.9

  把2.6.6升级到2.7(参见linux升级python到2.7版本)再试试:

[root@centos ~]# nvm install 12.13.
Downloading and installing node v12.13.0...
Downloading https://nodejs.org/dist/v12.13.0/node-v12.13.0-linux-x86.tar.xz... curl: () The requested URL returned error: Not Found
Binary download from https://nodejs.org/dist/v12.13.0/node-v12.13.0-linux-x86.tar.xz failed, trying source.
grep: /root/.nvm/.cache/bin/node-v12.13.0-linux-x86/node-v12.13.0-linux-x86.tar.xz: No such file or directory
Provided file to checksum does not exist.
Binary download failed, trying source.
Detected that you have CPU core(s)
Number of CPU core(s) less than or equal to , running in single-threaded mode
Local cache found: $NVM_DIR/.cache/src/node-v12.13.0/node-v12.13.0.tar.xz
Checksums match! Using existing downloaded archive $NVM_DIR/.cache/src/node-v12.13.0/node-v12.13.0.tar.xz
$>./configure --prefix=/root/.nvm/versions/node/v12.13.0 <
WARNING: failed to autodetect C++ compiler version (CXX=g++)
ERROR: Did not find a new enough assembler, install one or build with
--openssl-no-asm.
Please refer to BUILDING.md
nvm: install v12.13.0 failed!

  还是失败了,换个低版本试试:

[root@centos /]# nvm install 8.16.
Downloading and installing node v8.16.2...
Downloading https://nodejs.org/dist/v8.16.2/node-v8.16.2-linux-x86.tar.xz...
########################################### 59.8%
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v8.16.2 (npm v6.4.1)
Creating default alias: default -> 8.16. (-> v8.16.2 *)

  这次可以了:

[root@centos /]# node -v
v8.16.2

linux安装nvm和nodejs的更多相关文章

  1. linux安装nvm node版本管理器 nvm常用命令 部署node服务器环境

    1,nvm git地址点击打开链接,安装命令 curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh ...

  2. 安装nvm 切换nodejs版本

    删除已安装的nodejs--------------------------------------------------------------- #查看已经安装在全局的模块,以便删除这些全局模块 ...

  3. linux 安装 nvm, node.js, npm

    vscode在wsl中开发node应用,如何安装nvm? git clone git@github.com:nvm-sh/nvm.git ~/.nvm 设置淘宝registry npm config ...

  4. Windows 下安装 nvm 管理 nodejs 版本

    摘自https://segmentfault.com/a/1190000007612011 1. 下载安装与使用 Github: Download nvm-windows --- nvm-setup. ...

  5. linux 安装nvm,通过nvm安装node

    1,nvm git地址点击打开链接,安装命令 curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh ...

  6. linux 安装 nvm

    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash 或者 wget -qO- htt ...

  7. 【进击后端】linux安装最新版nodejs

    nodejs下载:https://nodejs.org/zh-cn/download/ 1.cd /root/download 2.wget https://nodejs.org/dist/v6.11 ...

  8. mac OS 安装 nvm

    nvm官网 https://github.com/creationix/nvm nvm,node,npm之间的区别 nvm:nodejs 版本管理工具 一个 nvm 可以管理很多 node 版本和 n ...

  9. Linux 安装nodejs环境以及路径配置

    linux安装nodejs有2种方式一种简单的,解压即可用:另一种,通过下载source code ,通过编译,make,make install命令来安装. 这里只讲第一种,简单方便.不需要执行ma ...

随机推荐

  1. 个人作业第五次——Alpha项目测试

    这个作业属于哪个课程 https://edu.cnblogs.com/campus/xnsy/2019autumnsystemanalysisanddesign/ 这个作业的要求在哪里 https:/ ...

  2. Pytorch autograd,backward详解

    平常都是无脑使用backward,每次看到别人的代码里使用诸如autograd.grad这种方法的时候就有点抵触,今天花了点时间了解了一下原理,写下笔记以供以后参考.以下笔记基于Pytorch1.0 ...

  3. HDU5036(bitset加速传递闭包+期望)

    HDU5036 题解 题目链接 思路: 求出破坏or打开所有门所需要的期望炮弹数量,那么根据期望的线性性质,我们可以求出每一个门的期望值最后累加起来就行了. 我们最后的目标就是求对于一个门\(i\), ...

  4. cmake 编译windows程序

    cmake 编译windows程序 cmake 编译windows程序 cmake 编译windows程序 尽量使用  尽量使用 尽量使用 https://www.cnblogs.com/liujia ...

  5. Mysql 日常

    Mysql 日常总结 做报表的时候经常会使用 if 来帮助统计 select count(if(key=1,1,NULL)) from atable where ... 当然,也支持选择 select ...

  6. async/await 和 trycatch/throwable机制类似

    async/await 和 trycatch/throwable机制类似

  7. 20-2 树莓派搭建服务器 Tornado Web服务器

    Drive.google.com/drive/folders/1ahbeoEHkjxoo4NV1wReOmpoRWbl448z- 1.Tornado简介 Tornado一款使用 Python 编写的, ...

  8. LeetCode 886. Possible Bipartition

    原题链接在这里:https://leetcode.com/problems/possible-bipartition/ 题目: Given a set of N people (numbered 1, ...

  9. linux学习16 Linux用户和组管理命令演练和实战应用

    一.上集回顾 1.bash globing,IO重定向及管道 glob:*,?,[],[^] IO重定向: >,>>, 2>,2>> &>,& ...

  10. luogu_4568: 飞行路线

    洛谷4568: 飞行路线 题意: 给定一张无向图有\(n\)个点编号为\(0\)到\(n-1\).共有\(m\)条边,每条边有一个边权. 可以选择\(k\)条边将边权改变为\(0\),给定起点和终点, ...