Ask coding questions

← Back to all posts
How to change node version
mirzabhakti (0)

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?

Answered by Coder100 (18118) [earned 5 cycles]
View Answer
Coder100 (18118)

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"
  "...": "..."
mirzabhakti (0)

@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.
Coder100 (18118)

@mirzabhakti oh delete the node_modules file lol

mirzabhakti (0)

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

Coder100 (18118)

usually it's as easy as:

rm node_modules


rm -r node_modules


mirzabhakti (0)

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

CoffeeGuy (1)

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

karlhorky (0)

@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 here:

Coder100 (18118)

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

SomeGuy19 (0)

@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??


Try to use npm i [email protected]