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:
const path: string = __filename;
Practical example
const path: string = __filename;
console.log(path); // C:\Project\index.js
Example output:
C:\Project\index.js