Answer the question
In order to leave comments, you need to log in
What's the ./ in a relative file path?
Hello dear programmers.
I started to study NODE.JS, however, as always, it does not do without difficulties, and here is another one.
While reading the tutorial ( https://metanit.com/web/nodejs/2.1.php), I came across a line that says
...to include your modules, you need to pass a relative path to the require function...
var greeting = require("./greeting");
../
, it is written here ./
, and both files are in the same directory, and somehow no quotes are needed. var greeting = require("greeting");
Answer the question
In order to leave comments, you need to log in
'. /' so modules are connected from the same directory as the file in which the connection is made.
Open a command prompt and type dir
under Windows ls -la
or Mac or Linux. At the beginning of the list there will be two items: .
and ..
. The first one points to the current directory, the second one to the parent directory. These are logical links, each directory has its own.
This is how the paths are set: that ./someDir/someFile
means: starting from the current directory, find the directory someDir, and in it the file someFile. ../someDir/someFile
means: starting from the parent directory, find someDir, and in it someFile.
Both are relative paths because they are built relative to the current directory.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question