T
T
Temych2019-06-25 12:36:49
JavaScript
Temych, 2019-06-25 12:36:49

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)

Something like that. I think it has to do with index.js and the . Maybe my question is stupid. Maybe not. Don't know.var greeting = require(".message");

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
fgvnovoross, 2019-12-17
@fgvnovoross

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 message
or
npm install message
or something like that, then remove the dot:require("message")

A
AlmondPark33609, 2021-10-11
@AlmondPark33609

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 question

Ask a Question

731 491 924 answers to any question