← Back to Community
How Can I Update Node.JS Versıon?
Profile icon
CroxyTheDev

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.

Voters
Profile icon
XoloGamerz
Profile icon
ShaunB19
Profile icon
Smart09Codes
Profile icon
AZURAROBO
Profile icon
Michael-Master13
Profile icon
ownerbinc
Profile icon
JuanManuel63
Profile icon
TheGaelicKing
Profile icon
progameplayer27
Profile icon
DiscorBotMaker
Comments
hotnewtop
Profile icon
CrazyVideoGamer

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 bash 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 in shell.
Note: You must run this every time you reopen the repo.

Profile icon
IronBoy345

@CrazyVideoGamez how do irun this in my node.js project?

Profile icon
CrazyVideoGamer

@IronBoy345 Oh, just run "bash file.sh" where file.sh has this script. sorry for not clarifying

Profile icon
IronBoy345

@CrazyVideoGamez thanks, but where do i run bash file.sh? I have a node.js script. Should I run in the console or in index.js? I tried both the places, but i get an error message saying file is undefined identifier :( I want to host a minecraft bot for keeping my aternos server online but it requires node version 14.x.x+

Profile icon
CrazyVideoGamer

@IronBoy345 oh, you need to run it at the shell, which should be next to the console. BTW, there is a much simpler method. I recommend you just use the solution outlined in my other comment.

Profile icon
IronBoy345

@CrazyVideoGamez thanks a lot, I ran it in the shell and got the output message "now using node version 14. and blah blah blah".
And then i ran those other commands. But i still got the error message saying update to node verson >= 14.x.x :( sorry for bothering you

Profile icon
Skripthut

@IronBoy345 You can run this automatically with a .replit file in your main directory.
I made an example repl (read the README file).

Sadly, repl.it's IDE is still TypeScript, so as you can see in my example index.js file, repl.it sees it as invalid syntax.

Profile icon
Skripthut

@CrazyVideoGamer Tysm for this! I thought I'd have to find another online IDE so I can use Node's up-to-date features, since I'm always (and currently) on my phone, and repl.it's always my go-to.

Now I know I can stay!

Profile icon
AdamPetrovszki

@Skripthut Is this still working?

Profile icon
Skripthut

@AdamPetrovszki Yep, works fine for me!

Profile icon
AdamPetrovszki

@Skripthut I'm sorry but in your example when I type in node -v it still shows 12.22.4. Am I doing something wrong?

Profile icon
CrazyVideoGamer

@AdamPetrovszki Made some changes, should work now

Profile icon
CrazyVideoGamer

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]'

Profile icon
[deleted]

paste this in shell
npm init -y && npm i --save-dev [email protected] && npm config set prefix=$(pwd)/node_modules/node && export PATH=$(pwd)/node_modules/node/bin:$PATH

Profile icon
ShinerZoch

I don't know if you still need it, but I was able to update Nix to the latest LTS Version of node. You can find the repl here: https://replit.com/@ShinerZoch/LTS-NodeJS?v=1

Basically what its doing is updating Nix and then installing the latest LTS Version of NodeJS. You can fork it and just hit run. It only updates when there is an update to do.

Profile icon
randomlylelo

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.

Profile icon
Coder100

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

Profile icon
TheForArkLD

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