DEV Community

AozoraDev
AozoraDev

Posted on

Getting Node.js 16 in Replit

Hey! It's me, Aozora and this is my first post on DEV.

Anyway, get to the point.
Discord.js v13 has been released with additional features like slash command, button, select menu, and context menu (coming soon) but Discord.js v13 requires Node.js 16.6 or above to work properly.
Unfortunately this is a nightmare for Replit users because Replit only supports v12 for Node.js and v14 for Bash.

Hey, don't worry. Here I will tell you the solution. Did you know that Replit has just released Nix (Beta) as a new programming language choice?
Well... We'll use that.
Oh, you don't know what Nix is?
You guys look it up yourself on Wikipedia because I'm... you know, kind of lazy.
Anyway, let's get started.

  1. Go grab some snacks because reading without eating is boring.

  2. Create a new project in your Replit then select Nix (beta) as your project language.
    DaProject

  3. After the editor opens, press 3 dots (I don't know what it's called) then press Show config files.
    DaOptions

  4. Press the replit.nix file , delete all the codes that writed on it, then type this code (or you can use Ctrl + C and Ctrl + V if you are lazy.

    { pkgs }: {
      deps = [
        pkgs.nodejs-16_x
      ];
    }
    
  5. Press the .replit file then type this.

    run = "npm start"
    
  6. Don't forget to add this in your package.json.

      "scripts": {
        "start": "node index.js"
      },
    

After everything is done, run your project and something like Loading Nix environment... will appear in your project console.
And we're done. Now you can use Discord.js v13 in your Replit project.

Latest comments (0)