Package path error

error :
node:internal/modules/cjs/loader:598
throw e;
^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in D:\PROJETS\real discord bot\node_modules\discord-api-types\package.json
at exportsNotFound (node:internal/modules/esm/resolve:303:10)
at packageExportsResolve (node:internal/modules/esm/resolve:650:9)
at resolveExports (node:internal/modules/cjs/loader:591:36)
at Module._findPath (node:internal/modules/cjs/loader:668:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1130:27)
at Module._load (node:internal/modules/cjs/loader:985:27)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (D:\PROJETS\real discord bot\src\functions\handlers\handleCommands.js:2:20)
at Module._compile (node:internal/modules/cjs/loader:1376:14) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
node:internal/modules/cjs/loader:598
throw e;
^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in D:\PROJETS\real discord bot\node_modules\discord-api-types\package.json
at exportsNotFound (node:internal/modules/esm/resolve:303:10)
at packageExportsResolve (node:internal/modules/esm/resolve:650:9)
at resolveExports (node:internal/modules/cjs/loader:591:36)
at Module._findPath (node:internal/modules/cjs/loader:668:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1130:27)
at Module._load (node:internal/modules/cjs/loader:985:27)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (D:\PROJETS\real discord bot\src\functions\handlers\handleCommands.js:2:20)
at Module._compile (node:internal/modules/cjs/loader:1376:14) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
4 Replies
d.js toolkit
d.js toolkit9mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
cur10s
cur10sOP9mo ago
handleCommands :
const { REST } = require("@discordjs/rest");
const { Routes } = require('discord-api-types')
const fs = require("fs");

module.exports = (client) => {
client.handleCommands = async () => {
const commandFolders = fs.readdirSync("./src/commands");
for (const folder of commandFolders) {
const commandFiles = fs
.readdirSync(`./src/commands/${folder}`)
.filter((file) => file.endsWith(".js"));

const { commands, commandArray } = client;
for (const file of commandFiles) {
const command = require(`../../commands/${folder}/${file}`);
commands.set(command.data.name, command);
commandArray.push(command.data.toJSON());
console.log(
`Command : ${command.data.name} has been passed through the handler`
);
}
}
const clientId = "1213782624443834388";
const guildId = "1213484196572569600";
const rest = new REST({ version: "9" }).setToken(process.env.token);
try {
console.log("Started refreshing applications (/) commands.");
await rest.put(Routes.applicationGuildCommands(clientId, guildId), {
body: client.commandArray,
});

console.log("Succesfully reloaded application (/) commands.");
} catch (error) {
console.error(error);
}
};
};
const { REST } = require("@discordjs/rest");
const { Routes } = require('discord-api-types')
const fs = require("fs");

module.exports = (client) => {
client.handleCommands = async () => {
const commandFolders = fs.readdirSync("./src/commands");
for (const folder of commandFolders) {
const commandFiles = fs
.readdirSync(`./src/commands/${folder}`)
.filter((file) => file.endsWith(".js"));

const { commands, commandArray } = client;
for (const file of commandFiles) {
const command = require(`../../commands/${folder}/${file}`);
commands.set(command.data.name, command);
commandArray.push(command.data.toJSON());
console.log(
`Command : ${command.data.name} has been passed through the handler`
);
}
}
const clientId = "1213782624443834388";
const guildId = "1213484196572569600";
const rest = new REST({ version: "9" }).setToken(process.env.token);
try {
console.log("Started refreshing applications (/) commands.");
await rest.put(Routes.applicationGuildCommands(clientId, guildId), {
body: client.commandArray,
});

console.log("Succesfully reloaded application (/) commands.");
} catch (error) {
console.error(error);
}
};
};
Any help would be great, as i'm pretty new to discord.js and js in general ://
ahmood
ahmood9mo ago
discord-api-types/v10
cur10s
cur10sOP9mo ago
ow that works ! thank you very much 😄
Want results from more Discord servers?
Add your server