Ask coding questions

← Back to all posts
How Can I Update Node.JS Versıon?
h
CroxyTheDev (2)

I'm using Repl.it for hosting my Discord bot but Discord API Wrapper requires Node.js v12 version. But my project's Node.js version is v10. I don't know how can i update Node.js please help me.

Comments
hotnewtop
CrazyVideoGamez (7)

Or, If you want a simpler, but less permanent version, you can run npx [email protected]. Also, you could try npm install [email protected], so you don't have to keep installing it to use npx. Also, you can create an alias with alias node='npx [email protected]'

CrazyVideoGamez (7)

As I've said on https://repl.it/talk/ask/change-node-version/5924:
Actually, you can change the node version. Here I'm going to use nvm. My script for installing it and setting it up is right here:

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

# Don't copy + paste this
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

nvm install --lts
nvm use --lts



tput setaf 6;
printf "\n\n"
printf "If running node/nvm doesn't work, run:\n\n"
tput setaf 2;
printf 'export NVM_DIR="$HOME/.nvm" &&\n'
printf '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" &&\n'
printf '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" &&\n'
printf '\nnvm install --lts &&\nnvm use --lts\n'
tput setaf 6;
printf '\nOr, just copy and paste the commands inside the script.\n'
tput init

# Copy + paste this, without the : ' and the ending quote
: '

export NVM_DIR="$HOME/.nvm" &&
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" &&
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" &&

nvm install --lts &&
nvm use --lts

'

This will install the lts version, but you can change that to be a different version (using nvm install 14.15.4 if you want 14.15.4, and then running nvm use 14.15.4 to use the 14.15.4 version). By the way, this is assuming the code is contained in use_nvm.sh (so the echo at the end is correct). To run the code (again assuming it is stored in use_nvm.sh), just run bash use_nvm.sh
Note: You must run this every time you reopen the repo.


For your case, if you want to install Node.js v12, then instead of running nvm install --lts && nvm use --lts, you would want to use nvm install 12 && nvm use 12. So, here is the actually script (for you)

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

# Don't copy + paste this
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

nvm install --lts
nvm use --lts



tput setaf 6;
printf "\n\n"
printf "If running node/nvm doesn't work, run:\n\n"
tput setaf 2;
printf 'export NVM_DIR="$HOME/.nvm" &&\n'
printf '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" &&\n'
printf '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" &&\n'
printf '\nnvm install 12 &&\nnvm use 12\n'
tput setaf 6;
printf '\nOr, just copy and paste the commands inside the script.\n'
tput init

# Copy + paste this, without the : ' and the ending quote
: '

export NVM_DIR="$HOME/.nvm" &&
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" &&
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" &&

nvm install 12 &&
nvm use 12

'

Note: You must run this every time you reopen the repo.

randomlylelo (35)

What I would do is turn on explorer mode and run a node project (it would give you node 12). That's what I do when making discordjs projects.

Coder100 (16956)

Hello, you can't update node.js due to the repl.it permissions for the shell. So, just code with node.js v10 and if it seriously does not work for you, report it to bugs

TheForArkLD (772)

you can’t update nodejs...
try use other module.