Answer the question
In order to leave comments, you need to log in
What if the console in Visual Studio Code (discord.js) doesn't find the ".message" module?
I'm trying to write a bot. It seems that everything is fine with the code, and the cat wept there (one test command). I don’t understand programming and JavaScript at all, I did it according to guides. But when I tried to run it by writing to the console node .
, I got an error:
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '.message'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (D:\bot\index.js:7:16)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
var greeting = require(".message");
Answer the question
In order to leave comments, you need to log in
I understand that you were trying to make index.js and add. the message.js file that does the response to the command, right?
If yes, then it is logical what is wrong:
Try to write not , but
If you wrote to the consolerequire(".message")
require("./message")
npm messageor
npm install messageor something like that, then remove the dot:
require("message")
What is message? File? Module? For modules, use require('module') and for files, specify the path starting from the file with require: require('./file') require('../file')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question