Easiest way to get Node v16.6+ and NPM v7.20+ for your Discord.js v13 projects!
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 ;)
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
@TikiHed double check if the packages are installed correctly. If the problem continues, send the repl link if possible. Will look into it.
@Debarchito here is what it is ... forked, https://replit.com/@TikiHed/MBOT-132#index.js
@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.
@Debarchito worked, tysm .. apparently using dashes or dots won't work in the name?..
@TikiHed didn't check that. Maybe that's the case?
Thanks. it worked
Glad it worked.
@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
@VXZELL12345 Yeah. Creating a custom command handler is actually quite easy. I'll create one tomorrow and send you the repl link.
@Debarchito okay thank you very much
Thanks!
@TwitchUmiShark No problem ;)
"cannot execute a binary file"
@Tyler2P What did you type in the console?
@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.
@Tyler2P Ah that only happens when node isn't installed properly. But glad you got it working :)
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
@redninja25
bash node
isn't supposed to be a npm package. Can you link me to your repl?@Debarchito yeah, one sec.
@Debarchito https://replit.com/@redninja25/goose-I-guess
@redninja25 Ah you didn't create the
node
andnpm
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.@Debarchito I just did that, still spitting out the same error
@redninja25 Try forking my repl as the link you gave isn't working.
@Debarchito alright
@Debarchito
node: line 1: /home/runner/Node-vAny/node_modules/node/bin/node: No such file or directory
@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
@Debarchito I fixed the problem, node wasn't installed.
@redninja25 oh well. Glad you solved it.