I was trying to import the cubing.js module in nodejs so I can use in in my discord.js bot. However when I use the following import const {randomScrambleForEvent } = require('cubing/scramble')
I run in to the following error ‘Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath ‘./scramble’ is not defined by “exports” in C:UsersfindhDownloadstestcodenode_modulescubingpackage.json’.
I have imported other modules and have not gotten such an error. I made sure the module is imported by running npm i cubing
. However I can’t seem to fix this issue
Here is the complete code for the bot
`const { Client, Events, GatewayIntentBits, Intents } = require('discord.js');
const {randomScrambleForEvent } = require('cubing/scramble')
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.once('ready', () => {
console.log('Bot is ready!');
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if (interaction === 'ping') {
const scramble = await randomScrambleForEvent("333");
await interaction.reply(scramble);
}
});
client.login(BOT-TOKEN);`
I have also looked through the module itself. This is a part of the package.json file that seem relevant. I have looked through the documentation which mentions npm but I am unsure how to proceed. https://js.cubing.net/cubing/
"exports": {
"./alg": {
"import": "./dist/lib/cubing/alg/index.js",
"types": "./dist/lib/cubing/alg/index.d.ts"
},
"./bluetooth": {
"import": "./dist/lib/cubing/bluetooth/index.js",
"types": "./dist/lib/cubing/bluetooth/index.d.ts"
},
"./kpuzzle": {
"import": "./dist/lib/cubing/kpuzzle/index.js",
"types": "./dist/lib/cubing/kpuzzle/index.d.ts"
},
"./notation": {
"import": "./dist/lib/cubing/notation/index.js",
"types": "./dist/lib/cubing/notation/index.d.ts"
},
"./protocol": {
"import": "./dist/lib/cubing/protocol/index.js",
"types": "./dist/lib/cubing/protocol/index.d.ts"
},
"./puzzle-geometry": {
"import": "./dist/lib/cubing/puzzle-geometry/index.js",
"types": "./dist/lib/cubing/types/puzzle-geometry/index.d.ts"
},
"./puzzles": {
"import": "./dist/lib/cubing/puzzles/index.js",
"types": "./dist/lib/cubing/types-geometry/index.d.ts"
},
"./scramble": {
"import": "./dist/lib/cubing/scramble/index.js",
"types": "./dist/lib/cubing/scramble/index.d.ts"
},
"./search": {
"import": "./dist/lib/cubing/search/index.js",
"types": "./dist/lib/cubing/search/index.d.ts"
},
"./stream": {
"import": "./dist/lib/cubing/stream/index.js",
"types": "./dist/lib/cubing/stream/index.d.ts"
},
"./twisty": {
"import": "./dist/lib/cubing/twisty/index.js",
"types": "./dist/lib/cubing/twisty/index.d.ts"
}
}
Hamza Hafeez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.