Answer the question
In order to leave comments, you need to log in
How to get the root directory from a module?
In general, this directory structure is:
/app.js
/lib/View.js
/views/index.html
View.js reads index.html in the views folder. As you know, __dirname is different for each module. So I pass __dirname from app.js to the View.js instance to get the root directory there. It doesn't turn out very pretty. How else can I get the root directory of the main script from within any module?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question