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.
Once done, create a
node file in project directory and enter:
Now call node via:
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
bash node in your
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
bash npm --version and it prints 7.20.5! You can do the same for NPX!
Now, you are ready to rock ;)
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.
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
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