#An error i don't know how to fix..
90 messages · Page 1 of 1 (latest)
u mean this?:
or my package.json
nah that is fine
src/commands doesn't exist
your path should be ../commands/order.js etc in your index.js
like this?
import rolesCommand from '../command/roles.js';
👍
stil doesnt wiork
commands
you missed the s
ohh
SyntaxError: The requested module '../commands/order.js' does not provide an export named 'default'
still doesnt seem to work
import orderCommand from '../commands/order.js';
is the problem
the problem is the orderComman =d bit
how 🤔
what error does it show now
const commands = [OrderCommand, RolesCommand]; i call them there
did you try:
import * as OrderCommand from 'path'
in index.js
indeed
`import * as OrderCommand from 'path'
^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Identifier 'OrderCommand' has already been declared`
its been declared here: const commands = [OrderCommand, RolesCommand];
bruh.. we are running in circles. please show your index.js (remove your token when posting here)
you have to change stuff too when updating your code
wdym
line 4-5 also replace path with the actual path
you mean get rid of:
import OrderCommand from '../commands/order.js'; import RolesCommand from '../commands/roles.js';
ohhh
yes
either use ESM or CJS completely.
don't know what they are?
Google is your best friend
so which one am i using?
you should know, not me. it's your workspace
require is based of CJS
but u told me to put:
import * as OrderCommand from '../commands/order.js' import * as RolesCommand from '../commands/roles.js'
CommonJS uses the require('./file.js') syntax for importing other modules and the module.exports = syntax for exporting stuff from modules ESM uses the import {stuff} from './file.js' syntax for importing and the export stuff syntax for exports
and the rest of my code is using:
const { Client, GatewayIntentBits, Routes, ChatInputCommandInteraction, SortOrderType } = require('discord.js'); const { config } = require('dotenv'); const { REST } = require('@discordjs/rest');
not import
because that's what you showed me and I interpreted it in that sense. it's partially my fault too for not pointing out the mixture
so how do i make it just CommonJS
by putting const { OrderCommand } = require('../commands/order.js');
you need to change your exports everywhere you did it in ESM style too
but is that correct
I can't say if I don't know how you exported it in CJS
but for exporting should it have the same thing?
like that
again.. it depends on yourhow you export
i'll show u when i get back home on my pc

export is ESM syntax. use module.exports
which line
WebAssembly.Module.exports()
The WebAssembly.Module.exports() function returns an array containing descriptions of all the declared exports of the given Module.
oop, wrong one
?
line 35
got an error:
module.exports defualt rolesCommand.toJSON();
i put that but it says ; expected
even tho on the line before it has one
please.. that's not the syntax
pls can u just tell me ive been having this error for 2 days now
and i want to code
like this?
module.exports = { rolesCommand.toJSON }
^^
to json is a function
so what do i put
plus an object needs key-value pairs
..
but what do i put bc the website said that
this? const { rolesCommand } = require('../src/index.js')
the problem with this is that it requires you to have knowledge with basic js data type therefore if you don't it's hard to fully cover the whole point. I'd recommend you to visit one of the #resources (personally prefer javascript.info) to learn more on objects and destructuring assignment
please can u just tell me, im using codecademy and learning now
ive been doing it for a week
so please can u say what i need to write
if you want to destructure it in this way, you'd have to export with this same namespace and the value would be what you had exported earlier
actually nvm i have made them all ESM
import { OrderCommand } from '../commands/order.js'; ^^^^^^^^^^^^ SyntaxError: The requested module '../commands/order.js' does not provide an export named 'OrderCommand'
I literally have exported it
export default orderCommand.toJSON();