Y
Y
Yaroslav Ivanov2020-01-14 17:02:13
Node.js
Yaroslav Ivanov, 2020-01-14 17:02:13

How to include a file in node.js without specifying a directory level?

Hello
The module is connected via: var http = require("http");
The file is included via: var file = require("./file");
Node.js does not have to specify a direct path to the module; it will search for it in the current directory, one level higher, and so on.
Question: how to make node.js look for a file in the current directory, if it does not find it, then look for a level higher?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question