linux install nvm and nodejs

  Download nvm package:

[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

  The above tips related environment variables already in the configuration file / root / .bashrc to us automatically add in a good, need to re-enter ssh.

  As it says, after re-entering the ssh, start the installation nodejs and 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)

  Pick install the latest version 12.13.0, failed:

[root@centos ~]# nvm install 12.13.0
Downloading and installing node v12.13.0...
Downloading https://nodejs.org/dist/v12.13.0/node-v12.13.0-linux-x86.tar.xz...

curl: (22) The requested URL returned error: 404 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 1 CPU core(s)
Number of CPU core(s) less than or equal to 2, 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.7 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!

  Suggesting that there is no python2.7, under confirmation (version 2.6.6 installed by default):

[root@centos ~]# yum list installed | grep python
abrt-addon-python.i686
abrt-python.i686      2.0.8-43.el6.centos @anaconda-CentOS-201703281202.i386/6.9
dbus-python.i686      0.83.0-6.1.el6      @anaconda-CentOS-201703281202.i386/6.9
libproxy-python.i686  0.3.0-10.el6        @anaconda-CentOS-201703281202.i386/6.9
libreport-python.i686 2.0.9-33.el6.centos @anaconda-CentOS-201703281202.i386/6.9
libxml2-python.i686   2.7.6-21.el6_8.1    @anaconda-CentOS-201703281202.i386/6.9
newt-python.i686      0.52.11-4.el6       @anaconda-CentOS-201703281202.i386/6.9
python.i686           2.6.6-66.el6_8      @anaconda-CentOS-201703281202.i386/6.9
python-argparse.noarch
python-babel.noarch   0.9.4-5.1.el6       @os                                   
python-backports.i686 1.0-5.el6           @os                                   
python-backports-ssl_match_hostname.noarch
python -chardet.noarch 2.2 . 1 - 1 .el6 @os                                   
python-cheetah.i686   2.4.1-1.el6         @os                                   
python-configobj.noarch
python-crypto2.6.i686 2.6.1-2.el6         @os                                   
python-dmidecode.i686 3.10.15-1.el6       @anaconda-CentOS-201703281202.i386/6.9
python-iniparse.noarch
python -jinja2.i686     2.2 . 1 - 3 .el6 @os                                   
python-jsonpatch.noarch
python-jsonpointer.noarch
python-libs.i686      2.6.6-66.el6_8      @anaconda-CentOS-201703281202.i386/6.9
python-markdown.noarch
python-oauthlib.noarch
python-prettytable.noarch
python-pycurl.i686    7.19.0-9.el6        @anaconda-CentOS-201703281202.i386/6.9
python-pygments.noarch
python-requests.noarch
python-setuptools.noarch
python-six.noarch     1.9.0-2.el6         @os                                   
python-urlgrabber.noarch
python-urllib3.noarch 1.10.2-3.el6        @os                                   
rpm-python.i686       4.8.0-55.el6        @anaconda-CentOS-201703281202.i386/6.9

  The 2.6.6 upgrade to 2.7 (see linux python upgrade to version 2.7 ) and try again:

[root@centos ~]# nvm install 12.13.0
Downloading and installing node v12.13.0...
Downloading https://nodejs.org/dist/v12.13.0/node-v12.13.0-linux-x86.tar.xz...

curl: (22) The requested URL returned error: 404 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 1 CPU core(s)
Number of CPU core(s) less than or equal to 2, 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!

  Or failed, another lower version to try:

[root@centos /]# nvm install 8.16.2
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.2 (-> v8.16.2 *)

  This time it:

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

 

Guess you like

Origin www.cnblogs.com/wuxun1997/p/11778508.html