Learn to Code via Tutorials on Repl.it!

← Back to all posts
Easiest way to get Node v16.6+ and NPM v7.20+ for your Discord.js v13 projects!
Debarchito (20)

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.

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

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):

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

Replace <Your-Repl-Name> 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 ;)

Comments
hotnewtop
FredrickMarks (0)

Seems useful, but I plan to stick with nvm for most day-to-day stuff. Why? Because if I'm switching versions in nvm it's probably because I'm going to use lots of commands, for a while (hours/days), that all need to use that version. Using npx for this would work best if you've got one or two things to do in that version.

https://www.myaarpmedicare.work/

redninja25 (1)

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

Debarchito (20)

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

Debarchito (20)

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

redninja25 (1)

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

Debarchito (20)

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

redninja25 (1)

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

Debarchito (20)

@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

redninja25 (1)

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

Debarchito (20)

@redninja25 oh well. Glad you solved it.

TikiHed (4)

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

Debarchito (20)

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

Debarchito (20)

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

TikiHed (4)

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

Debarchito (20)

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

VXZELL12345 (2)

@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

Debarchito (20)

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

VXZELL12345 (2)

@Debarchito okay thank you very much

Tyler2P (0)

"cannot execute a binary file"

Debarchito (20)

@Tyler2P What did you type in the console?

Tyler2P (0)

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

Debarchito (20)

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