discordjs / discord.js-modules

Modularisation of discord.js (WIP)
Apache License 2.0
192 stars 30 forks source link

@discordjs/rest: Cannot find module 'timers/promises' #52

Closed BeeFox-sys closed 3 years ago

BeeFox-sys commented 3 years ago

Please describe the problem you are having in as much detail as possible:

In running a very slightly modified version of the code in the djs guide for updating commands, I have encountered this error:

Error: Cannot find module 'timers/promises'
Require stack:
- /mnt/c/Users/Fiona/Desktop/Code/discord-mod-bot/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js
- /mnt/c/Users/Fiona/Desktop/Code/discord-mod-bot/node_modules/@discordjs/rest/dist/lib/RequestManager.js      
- /mnt/c/Users/Fiona/Desktop/Code/discord-mod-bot/node_modules/@discordjs/rest/dist/index.js
- /mnt/c/Users/Fiona/Desktop/Code/discord-mod-bot/updateCommands.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/mnt/c/Users/Fiona/Desktop/Code/discord-mod-bot/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js:6:20)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)```

**Include a reproducible code sample here, if possible:**

```js
require("dotenv").config();
const {REST} = require("@discordjs/rest");
const {Routes} = require("discord-api-types/v9");

const commands = require("./commands.json");

const rest = new REST({"version": "9"}).setToken(process.env.TOKEN);

(async () => {

    try {

        console.log("Started refreshing application (/) commands.");

        if (process.argv.length) {

            await rest.put(
                Routes.applicationGuildCommands(process.env.CLIENT_ID, process.argv[0]),
                {"body": commands}
            );

        } else {

            await rest.put(
                Routes.applicationCommands(process.env.CLIENT_ID),
                {"body": commands}
            );

        }

        console.log("Successfully reloaded application (/) commands.");

    } catch (error) {

        console.error(error);

    }

})();

node updateCommands.js 748911244236554402```

**Further details:**

- discord.js version: main as of time of posting
- Node.js version: 14.16.1
- Operating system: WSL2 Ubuntu 18.4 on Windows 10
BeeFox-sys commented 3 years ago

Node version issue

Joan0o commented 3 years ago

shouldn't you like... fix it? I downloaded the recommended version

DTrombett commented 3 years ago

discord.js requires at least nodejs v16.6.

Joan0o commented 3 years ago

Oh alright

BeeFox-sys commented 3 years ago

yeah that was my mistake too, I was using node 14 rather then node 16