'Issues on installing nvm and updating nodejs on Ubuntu 18

I am using Ubuntu 18, and when I install nodejs, it only installs node version 8.10 even if I updated apt. So, I'm trying to use nvm to mange node version, but when I try to install nvm by typing following command line
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
I get this error:
curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number
verbose output:

  • Trying 168.219.61.252...
  • TCP_NODELAY set
  • Connected to 168.219.61.252 (168.219.61.252) port 8080 (#0)
  • ALPN, offering http/1.1
  • successfully set certificate verify locations:
  • CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs
  • TLSv1.3 (OUT), TLS handshake, Client hello (1):
  • error:1408F10B:SSL routines:ssl3_get_record:wrong version number
  • Closing connection 0 curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number
    I've looked through similar issues,but they were related to proxy setting, but I disabled proxy. I have no idea what's causing this issue. Any help would be appreciated. Thanks!


Solution 1:[1]

I tried this gist for a Docker container I was building using Ubuntu 18.04. I suppose it could work in your case, as shown below, without Docker commands. I suppose you can change NVM_DIR=/ to any path of your choice.

# replace shell with bash so we can source files
rm /bin/sh && ln -s /bin/bash /bin/sh

# nvm environment variables
export NVM_DIR=/
export NODE_VERSION=16.9.1

# download the nvm script from https://github.com/nvm-sh/nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

# install node and npm
source $NVM_DIR/nvm.sh \
    && nvm install v$NODE_VERSION \
    && nvm alias default v$NODE_VERSION \
    && nvm use default

# add node and npm to path so the commands are available
export NODE_PATH=$NVM_DIR/v$NODE_VERSION/lib/node_modules
export PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 intumwa