Skip to content
How to change node version
Profile icon
mirzabhakti

Im trying to build a discord bot recently. I tried to install the new discord.js version but i need to change the node version to 12 or higher. Tried to use this code on my package.json but doesnt work

"engines": { "node": "latest", "npm": "latest" }

is there any other way to change the node version?

You are viewing a single comment. View All
Profile icon
Coder100

You can install it.
Hit ctrl+shift+s:

npm i node

What you are looking for is npm as well, so:

npm i node npm

isn't that just beautiful :D
and for your package.json:

{ "...": "...", "dependencies": { "node": "latest", "npm": "latest" }, "...": "..." }
Profile icon
mirzabhakti

@Coder100
while i tried to install, it gave me an error

npm ERR! code EEXIST npm ERR! syscall mkdir npm ERR! path /home/runner/aestetikmod/node_modules npm ERR! errno -17 npm ERR! EEXIST: file already exists, mkdir '/home/runner/aestetikmod/node_modules' npm ERR! File exists: /home/runner/aestetikmod/node_modules npm ERR! Remove the existing file and try again, or run npm npm ERR! with --force to overwrite files recklessly.
Profile icon
Coder100

@mirzabhakti
oh delete the node_modules file lol

Profile icon
mirzabhakti

@Coder100
can you show me the way to delete the node_modules? lol

Profile icon
Coder100

um send repl

@mirzabhakti

Profile icon
Coder100

usually it's as easy as:

rm node_modules

and/or

rm -r node_modules

@mirzabhakti

Profile icon
mirzabhakti

@Coder100
oh that worked thank you. I kinda new to coding so i dont really know the commands & stuff are lol

Profile icon
Coder100

lol np :)

@mirzabhakti

Profile icon
CoffeeGuy

@Coder100
thx a lot for this, but is there any way, I can specify the version of node here? :)

Profile icon
karlhorky

@Coder100
this is great, thanks!

We are using this for Preflight, documented our whole journey getting top-level await and other new JavaScript / ES features running in repl.it here:

https://github.com/upleveled/preflight/issues/17

Profile icon
Coder100

no problem :D

@karlhorky

Profile icon
Coder100

sorry for the late reply, but

npm i [email protected]<version>

where <version> is the version you would like. It can also be latest, beta, and alpha assuming those are actual builds lol


@CoffeeGuy

Profile icon
SomeGuy19

@Coder100
um it says rm: cannot remove 'node_modules': Is a directory when i type rm node_modules how do I delete the node modules folder??

Profile icon
Coder100

rm -r node_modules

@SomeGuy19

Profile icon
DonovanEdwards

@Coder100
It says that there is no module called 'node:events' after trying this

Profile icon
ErrorbotTHE2nd

@Coder100
This dose not work:

npm ERR! code Unknown system error -122 npm ERR! syscall open npm ERR! path /home/runner/.npm/_cacache/tmp/61669aa1 npm ERR! errno -122 npm ERR! Unknown system error -122: Unknown system error -122, open '/home/runner/.npm/_cacache/tmp/61669aa1' npm ERR! code Unknown system error -122 npm ERR! syscall open npm ERR! path /home/runner/.npm/_cacache/tmp/d4998399 npm ERR! errno -122 npm ERR! Unknown system error -122: Unknown system error -122, open '/home/runner/.npm/_cacache/tmp/d4998399'
Profile icon
Coder100

nix exists now! Create a new nix repl and add nodejs-16_x to the packages.

@ErrorbotTHE2nd

Profile icon
ErrorbotTHE2nd

@Coder100
how do I do that? as I'm currently using a polygott repl (because of a temple I used)