Answer the question
In order to leave comments, you need to log in
Node.js: How to find out the path to an arbitrary file?
There is no js file.
Need to know the path to this file, for example, "C:/<...>/file.txt"?
Tell me, please, how to solve the problem?
Looking ahead, there are "__filename" and "__dirname" functions, but they give the path to the executable js file.
Answer the question
In order to leave comments, you need to log in
Maybe the path module will help?
var path = require('path');
path.resolve(__dirname, filename); // Относительный путь до файла от текущей директории
Either look for ready-made modules for searching files, or write a search yourself, or try to call some system functions (like "find" in unix)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question