Skip to content
← Back to Community
Easiest way to get Node v16.6+ and NPM v7.20+ for your Discord.js v13 projects!
Profile icon
Debarchito

So, Discord.js v13 is out and it requires Node v16.6+, which has become a headache. Even if you use Nix, you are stuck with v16.4 (at least at the time of writing). But not anymore! Here is how you can install v16.6+ (v16.6.1 for this post) in your Node.js repls! This will also work for any Node.js version.

First install Node v16.6.1 as a devDependency.

npm i -D [email protected]

Once done, create a node file in project directory and enter:

~/<Your-Repl-Name>/node_modules/node/bin/node [email protected]

Now call node via: bash node

Boom! v16.6.1! Since, it was installed as a devDependecy, it will stay even if you refresh or leave the repl page. One last step is to change every node to bash node in your package.json.

Now, its NPM time!

Install NPM as devDependency (7.20.5 for this post):

npm i -D [email protected]

Now, create a file named npm in the project directory. Enter the following:

~/<Your-Repl-Name>/node_modules/node/bin/node ~/<Your-Repl-Name>/node_modules/npm/bin/npm-cli.js [email protected]

Replace with your's. And done! Call bash npm instead of npm. Try bash npm --version and it prints 7.20.5! You can do the same for NPX!

Now, you are ready to rock ;)

Voters
Profile icon
chiqors
Profile icon
Shiv-DeviDevi
Profile icon
Llatepate
Profile icon
BulzyKrown
Profile icon
ByGoneNeutron
Profile icon
realboat
Profile icon
angi-mint
Profile icon
TikiHed
Profile icon
VXZELL12345
Profile icon
TwitchUmiShark
Comments
hotnewtop
Profile icon
redninja25

I get this when I replace 'node' with 'bash node'
--> npm install
npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name "bash node": name can only contain URL-friendly characters

npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2021-08-26T02_51_04_815Z-debug.log
exit status 1

Profile icon
Debarchito

@redninja25 bash node isn't supposed to be a npm package. Can you link me to your repl?

Profile icon
redninja25

@Debarchito yeah, one sec.

Profile icon
redninja25
Profile icon
Debarchito

@redninja25 Ah you didn't create the node and npm files in project directory. You should do that in order to run it. You can take a peek at my repl; specially the file structure.

Profile icon
redninja25

@Debarchito I just did that, still spitting out the same error

Profile icon
Debarchito

@redninja25 Try forking my repl as the link you gave isn't working.

Profile icon
redninja25

@Debarchito alright

Profile icon
redninja25

@Debarchito
node: line 1: /home/runner/Node-vAny/node_modules/node/bin/node: No such file or directory

Profile icon
Debarchito

@redninja25 well I mentioned that in the article; you need to change the name according to your repl name. For me it was Node-vAny

Profile icon
redninja25

@Debarchito I fixed the problem, node wasn't installed.

Profile icon
Debarchito

@redninja25 oh well. Glad you solved it.

Profile icon
TikiHed

worked when I forked it, but not when I renamed it?
node: line 1: /home/runner/MBOT-13.2/node_modules/node/bin/node: No such file or directory

Profile icon
Debarchito

@TikiHed double check if the packages are installed correctly. If the problem continues, send the repl link if possible. Will look into it.

Profile icon
TikiHed
Profile icon
Debarchito

@TikiHed When I switched to shell view in your repl, it showed the name as 80A4SzP7Q2z instead of MBOT-13.2. Try replacing the name with that 80... and lemme know if it works.

Profile icon
TikiHed

@Debarchito worked, tysm .. apparently using dashes or dots won't work in the name?..

Profile icon
Debarchito

@TikiHed didn't check that. Maybe that's the case?

Profile icon
VXZELL12345

Thanks. it worked

Profile icon
Debarchito

Glad it worked.

Profile icon
VXZELL12345

@Debarchito hi sorry to disturb you but do you know how to make a command handler in discord.js v13, because i dont understand it very well in the documentation

Profile icon
Debarchito

@VXZELL12345 Yeah. Creating a custom command handler is actually quite easy. I'll create one tomorrow and send you the repl link.

Profile icon
VXZELL12345

@Debarchito okay thank you very much

Profile icon
TwitchUmiShark

Thanks!

Profile icon
Debarchito

@TwitchUmiShark No problem ;)

Profile icon
Tyler2P

"cannot execute a binary file"

Profile icon
Debarchito

@Tyler2P What did you type in the console?

Profile icon
Tyler2P

@Debarchito I followed the exact steps you provided and bash node returns cannot execute a binary file however this post was a good alternative for downloading node.js version 16.

Profile icon
Debarchito

@Tyler2P Ah that only happens when node isn't installed properly. But glad you got it working :)