Ask coding questions

← Back to all posts
How Can I Update Node.JS Versıon?
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
TheGaelicKing
progameplayer27
DiscorBotMaker
CroxyTheDev
Comments
hotnewtop
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]'

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:

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.


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)

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

IronBoy345

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

CrazyVideoGamer

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

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+

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.

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

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.

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!

AdamPetrovszki

@Skripthut Is this still working?

Skripthut

@AdamPetrovszki Yep, works fine for me!

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?

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.

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

TheForArkLD

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