J
J
JackShcherbakov2017-10-16 23:12:19
Node.js
JackShcherbakov, 2017-10-16 23:12:19

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...

And below is the code.
var greeting = require("./greeting");
But after the usual relative paths that start with ../, it is written here ./, and both files are in the same directory, and somehow no quotes are needed.
I searched the Internet for articles and lessons on relative paths, but there was no such syntax anywhere! Also just...
var greeting = require("greeting");
...doesn't work
Are there any articles explaining this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Coder321, 2017-10-16
@JackShcherbakov

'. /' so modules are connected from the same directory as the file in which the connection is made.

K
Konstantin Kitmanov, 2017-10-17
@k12th

Open a command prompt and type dirunder Windows ls -laor 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/someFilemeans: starting from the current directory, find the directory someDir, and in it the file someFile. ../someDir/someFilemeans: 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 question

Ask a Question

731 491 924 answers to any question