How Can I Update Node.JS Versıon?
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.
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]'
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
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.
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.
you can’t update nodejs...
try use other module.
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 runningnvm 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 runbash use_nvm.sh
in shell.Note: You must run this every time you reopen the repo.
@CrazyVideoGamez how do irun this in my node.js project?
@IronBoy345 Oh, just run "bash file.sh" where file.sh has this script. sorry for not clarifying
@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+
@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.
@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
@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.
@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!
@Skripthut Is this still working?
@AdamPetrovszki Yep, works fine for me!
@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?
@AdamPetrovszki Made some changes, should work now