EN
TypeScript / Node.js - get current script directory
4 points
In this article, we would like to show you how to get the current script directory in Node.js.
As current script directory we understand the directory where executed script is located.
Quick solution:
xxxxxxxxxx
1
const directory: string = __dirname;
Where: directory
variable contains path to the directory.
xxxxxxxxxx
1
const directory: string = __dirname;
2
3
console.log(directory); // C:\Project
Example output:
xxxxxxxxxx
1
C:\Project