EN
TypeScript / Node.js - get current script path
8 points
In this article, we would like to show you how to get the currently executed script path in Node.js.
Quick solution:
xxxxxxxxxx
1
const path: string = __filename;
xxxxxxxxxx
1
const path: string = __filename;
2
3
console.log(path); // C:\Project\index.js
Example output:
xxxxxxxxxx
1
C:\Project\index.js