下载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. likely和unlikely是如何对代码的优化?

             在执行if判断时,可以使用GCC提供了__builtin_expect对代码进行优化,可以提高代码的运行速度,参考GCC手册的"3.10 Options That Cont ...

  2. JavaFX 井字棋游戏

    利用JavaFX设计一个井字棋游戏,其中包括了能够与玩家对战的AI.AI的实现相比五子棋来说要简单得多,可以保证AI在后手情况下绝对不会输,具体实现如下: /* * To change this li ...

  3. matplotlib---插值画二维、三维图

    一.画二维图 1.原始数据(x,y) import matplotlib.pyplot as plt import numpy as np #数据 X = np.array(list(i for i ...

  4. python基础笔记-列表

    列表是最常用的Python数据类型,它可以作为一个方括号内的逗号分隔值出现. 列表的数据项不需要具有相同的类型 创建一个列表,只要把逗号分隔的不同的数据项使用方括号括起来即可. def main(): ...

  5. 将Eclipse设置为黑色主题

    将Eclipse设置为黑色主题 觉得黑色的主题&配色很高大上,于是花了点时间实践出下面一种方法. 修改代码编辑区配色 修改整个软件主题 先上成果图: 但是进度条依旧是白色的,不知道怎么弄了╮( ...

  6. spark调优——算子调优

    算子调优一:mapPartitions 普通的map算子对RDD中的每一个元素进行操作,而mapPartitions算子对RDD中每一个分区进行操作.如果是普通的map算子,假设一个partition ...

  7. matplotlib双y周实例e

    import pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport pymysqlimport warningsimp ...

  8. [Algorithm] 122. Best Time to Buy and Sell Stock II

    Previous one: https://www.cnblogs.com/Answer1215/p/11974453.html Say you have an array for which the ...

  9. Numpy | 15 数学函数

    NumPy 包含大量的各种数学运算的函数,包括三角函数,算术运算的函数,复数处理函数等. 三角函数 NumPy 提供了标准的三角函数:sin().cos().tan(). import numpy a ...

  10. 9-网页,网站,微信公众号基础入门(使用PHP实现微信token验证)

    https://www.cnblogs.com/yangfengwu/p/11062422.html 这一节看怎么用PHP实现上一节的功能 关掉上一节的 学了这么久,忘了告诉大家怎么关闭程序了.... ...