Veinify
Veinify

Reputation: 35

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './src/util/Constants.js' is not defined by \"exports\"

I'm having trouble while coding my discord bot. Whenever i run this code:

const Constants = require('discord.js/src/util/Constants.js')
Constants.DefaultOptions.ws.properties.$browser = `Discord iOS`

I kept getting this error.

  Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './src/util/Constants.js' is not defined by \"exports\" in /home/runner/VerifyBot/node_modules/discord.js/package.json

I'm using node v12.18.4 and discord.js v12.3.1. Any ideas?

Upvotes: 0

Views: 1735

Answers (1)

T. Dirks
T. Dirks

Reputation: 3676

As the error suggests, the subpath in your require statement is not defined in Discord JS' package.json. If you want to get the Constants, you can do so by using the following line of code:

const { Constants } = require('discord.js');

Alternatively, the following will work as well:

const Discord = require('discord.js');
const Constants = Discord.Constants;

Upvotes: 1

Related Questions