DEV Community

Discussion on: How to set up a Discord music bot (Updated December 2021)

Collapse
 
dgyh profile image
dgyh

Hello, i did create a config.json file but it still says this even though i saved everything:

C:\Users\me\Downloads\sateenkaari>node .
internal/modules/cjs/loader.js:964
throw err;
^

Error: Cannot find module '../../config.json'
Require stack:

  • C:\Users\me\Downloads\sateenkaari\index.js at Function.Module._resolveFilename (internal/modules/cjs/loader.js:961:17) at Function.Module._load (internal/modules/cjs/loader.js:854:27) at Module.require (internal/modules/cjs/loader.js:1023:19) at require (internal/modules/cjs/helpers.js:72:18) at Object. (C:\Users\Kukka\Downloads\sateenkaari\index.js:34:24) at Module._compile (internal/modules/cjs/loader.js:1128:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10) at Module.load (internal/modules/cjs/loader.js:983:32) at Function.Module._load (internal/modules/cjs/loader.js:891:14) at Function.executeUserEntryPoint as runMain { code: 'MODULE_NOT_FOUND', requireStack: [ 'C:\Users\me\Downloads\sateenkaari\index.js' ] }

any suggestions?

Collapse
 
galnir profile image
Nir

Did you place it in the root of the project? (same place as index.js)

Collapse
 
dgyh profile image
dgyh

If you mean dragging the config.json into the index.js file, it wont allow. If you mean placing the config.json into the sateenkaari folder (the folder where all of the package.json files etc. are, then I did that.

Thread Thread
 
galnir profile image
Nir • Edited

I think you are trying to import it in a wrong way, in your index.js file did you try to require("../../config.json")?

It should be only "config.json" if so

Thread Thread
 
dungcan profile image
DungCan

internal/modules/cjs/loader.js:305
throw err;
^

Error: Cannot find module 'C:\Users\Truong Anh\Desktop\bot1\index.js'. Please verify that the package.json has
a valid "main" entry
?[90m at tryPackage (internal/modules/cjs/loader.js:297:19)?[39m
?[90m at Function.Module._findPath (internal/modules/cjs/loader.js:528:18)?[39m
?[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:784:27)?[39m
?[90m at Function.Module._load (internal/modules/cjs/loader.js:690:27)?[39m
?[90m at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)?[39m
?[90m at internal/main/run_main_module.js:17:11?[39m {
code: ?[32m'MODULE_NOT_FOUND'?[39m,
path: ?[32m'C:\Users\Truong Anh\Desktop\bot1\package.json'?[39m,
requestPath: ?[32m'C:\Users\Truong Anh\Desktop\bot1'?[39m
}

this is my trouble error
any suggestions to help me?

Thread Thread
 
galnir profile image
Nir • Edited

Um do you have a package.json file?
If you cloned mine just run npm install

Thread Thread
 
dgyh profile image
dgyh • Edited

Seems like the problem doesn't occur anymore. Now it has to display an error like this one:

Structures.extend('Guild', Guild => {
^

TypeError: Cannot read property 'extend' of undefined
at Object. (C:\Users\me\Downloads\sateenkaari\index.js:6:12)
[90m at Module._compile (internal/modules/cjs/loader.js:1128:30)[39m
[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)[39m
[90m at Module.load (internal/modules/cjs/loader.js:983:32)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:891:14)[39m
[90m at Function.executeUserEntryPoint as runMain[39m
[90m at internal/main/run_main_module.js:17:47[39m

Thread Thread
 
galnir profile image
Nir

you probably did not install discord.js master, hit

npm i discordjs/discord.js