How to install node 13+ (Guide)

Thank you @random!

I converted what you shared into a script that runs on npm start it seems to install node 13 properly. The only downside is a much slower startup time.

First I made a file install_node_13.sh with @random’s code

# https://support.glitch.com/t/how-to-install-node-13-guide/20430
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
export NVM_DIR="/app/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm --version
nvm install node
nvm use node

Then I modified by package.json

{
...
...
  "scripts": {
    "start": "bash install_node_13.sh && node server.js"
  },
...
...
}

The resulting logs

logs

node v12.0.0, with pnpm
3:10 PM
Installing...
3:10 PM
Performing headless installation
3:11 PM
3:11 PM
Total install time: 29569ms
 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
3:11 PM
                                 Dload  Upload   Total   Spent    Left  Speed
3:11 PM

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:05 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:05 --:--:--     0
100 11329  100 11329    0     0   1793      0  0:00:06  0:00:06 --:--:--  1810
3:11 PM
=> Downloading nvm from git to '/app/.nvm'
3:11 PM
Cloning into '/app/.nvm'...
3:11 PM

=> * (HEAD detached at v0.33.0)
3:11 PM
  master
3:11 PM
=> Compressing and cleaning up git repository
3:11 PM
3:13 PM
=> Profile not found. Tried  (as defined in $PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.
3:13 PM
=> Create one of them and run this script again
3:13 PM
=> Create it (touch ) and run this script again
3:13 PM
   OR
3:13 PM
=> Append the following lines to the correct file yourself:
3:13 PM
3:13 PM
export NVM_DIR="/app/.nvm"
3:13 PM
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
3:13 PM
=> Close and reopen your terminal to start using nvm or run the following to use it now:
3:13 PM
3:13 PM
export NVM_DIR="/app/.nvm"
3:13 PM
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
3:13 PM
0.33.0
3:13 PM
Downloading and installing node v14.3.0...
3:13 PM
Downloading https://nodejs.org/dist/v14.3.0/node-v14.3.0-linux-x64.tar.xz...
3:13 PM

#                                                                          2.1%
##                                                                         3.4%
####                                                                       6.4%
########                                                                  11.9%
##########                                                                14.3%
##############                                                            19.7%
###############                                                           21.9%
##################                                                        25.5%
####################                                                      28.4%
######################                                                    31.3%
########################                                                  34.4%
##########################                                                37.2%
############################                                              40.2%
###############################                                           43.8%
################################                                          45.3%
###################################                                       49.5%
#####################################                                     52.7%
########################################                                  55.8%
##########################################                                58.6%
############################################                              61.7%
##############################################                            64.2%
###############################################                           66.2%
#################################################                         69.0%
####################################################                      73.5%
#######################################################                   76.5%
#########################################################                 79.2%
###########################################################               82.6%
############################################################              84.2%
##############################################################            86.3%
################################################################          89.9%
####################################################################      94.6%
######################################################################    97.4%
######################################################################## 100.0%
3:13 PM
3:13 PM
Checksums matched!
3:13 PM
Now using node v14.3.0 (npm v6.14.5)
3:14 PM
Creating default alias: default -> node (-> v14.3.0)
3:14 PM
Now using node v14.3.0 (npm v6.14.5)
3:14 PM
💑🌄 Your app is listening on port 3000
3 Likes