"config" is not defined

ReferenceError: config is not defined
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js:11:14)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
ReferenceError: config is not defined
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js:11:14)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
58 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
shadow1111
shadow1111OP2y ago
const { Client, GatewayIntentBits, Partials } = require('discord.js');

const client = new Client({ intents: [GatewayIntentBits.Guilds], partials: [Partials.Channel] });
const config = require('./config.json');
config();



client.on('ready', () => {
console.log(`${client.user.tag} is ready to go!`);
})


client.login(config.TOKEN);
const { Client, GatewayIntentBits, Partials } = require('discord.js');

const client = new Client({ intents: [GatewayIntentBits.Guilds], partials: [Partials.Channel] });
const config = require('./config.json');
config();



client.on('ready', () => {
console.log(`${client.user.tag} is ready to go!`);
})


client.login(config.TOKEN);
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
it is saved
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
what guid e
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
send
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs2y ago
guide Creating Your Bot: Creating the main file read more
shadow1111
shadow1111OP2y ago
still dont work v12 yea
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
Error: Cannot find module './config.js'
Require stack:
- C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js:2:19)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',

requireStack: [ 'C:\\Users\\csj25\\OneDrive\\Desktop\\discordbot\\src\\index.js' ]
Error: Cannot find module './config.js'
Require stack:
- C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js:2:19)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',

requireStack: [ 'C:\\Users\\csj25\\OneDrive\\Desktop\\discordbot\\src\\index.js' ]
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
oh nvm ok now
Error: Cannot find module './config.json'
Require stack:
- C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js:2:19)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\\Users\\csj25\\OneDrive\\Desktop\\discordbot\\src\\index.js' ]
}

Node.js v18.16.1
Error: Cannot find module './config.json'
Require stack:
- C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js:2:19)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\\Users\\csj25\\OneDrive\\Desktop\\discordbot\\src\\index.js' ]
}

Node.js v18.16.1
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
do i move it in my source folder?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
soo const { TOKEN } = require('src/.config.json'); ?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs2y ago
- File paths explained in detail: learn more - . refers to the current directory - .. refers to the parent directory - Node path module: learn more
shadow1111
shadow1111OP2y ago
dont know what that is just say
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
i do but ive never had to do this yall shoulda never dropped support for v12<:skull_lmao:990395587528626236>
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
nah ill just remove it out of the source folder
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
still the same error
Error: Cannot find module './config.json'
Require stack:
- C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js:2:19)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\\Users\\csj25\\OneDrive\\Desktop\\discordbot\\src\\index.js' ]
}
Error: Cannot find module './config.json'
Require stack:
- C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js:2:19)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\\Users\\csj25\\OneDrive\\Desktop\\discordbot\\src\\index.js' ]
}
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
thats what you showed me
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
<:skull_lmao:990395587528626236>
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
thats what it is
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
okk? <:skull_lmao:990395587528626236>
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
took it out of the src folder and
TypeError: config is not a function
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\index.js:6:1)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47

Node.js v18.16.1
TypeError: config is not a function
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\index.js:6:1)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47

Node.js v18.16.1
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
okk? thats what you showed me lmao this isnt support <:skull_lmao:990395587528626236>
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
ok its gone and still an error
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
ReferenceError: config is not defined
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\index.js:5:1)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
ReferenceError: config is not defined
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\index.js:5:1)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const { TOKEN } = require('./config.json');

const client = new Client({ intents: [GatewayIntentBits.Guilds], partials: [Partials.Channel] });
config();



client.on('ready', () => {
console.log(`${client.user.tag} is ready to go!`);
})


client.login(TOKEN);
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const { TOKEN } = require('./config.json');

const client = new Client({ intents: [GatewayIntentBits.Guilds], partials: [Partials.Channel] });
config();



client.on('ready', () => {
console.log(`${client.user.tag} is ready to go!`);
})


client.login(TOKEN);
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
you said config(); defined it yesterday
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
cus neither work
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
jus nvm bro discord.py is easier
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
not an opinion everyone says it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
im good lil bro
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
apu
apu11mo ago
@Jô 🌈🦄 I want to thank you for resolving this problem and I found you on dogeHaHa I googled so many pages to deal with my Discord Bot and your grammars helped A LOT🫡 Though you seems a little pissed kek
Want results from more Discord servers?
Add your server