Answer the question
In order to leave comments, you need to log in
Why does the included file not see the modules?
Good afternoon. I would like not to include mysql, bcrypt, passport and so on in each file, but only in the start app.js file. But I have no idea how to do this, I include a file with a function using the modules above, but it does not sees and I get errors.
I am attaching the file like thisrequire('./config.js')
Answer the question
In order to leave comments, you need to log in
JavaScript is not PHP. Here, the file is not substituted for require, but a method, function, class, or something else is imported from the included file. However, you cannot use functions unless they are imported and exported in the file itself.
Read documentation on modules: https://learn.javascript.ru/modules
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question