Here is my issue: I want to use NodeJS's __filename as value of some property. When creating a new instance of that class from another file, the property filename gets __filename value of the file where the class was created, not __filename of the file where I created the instance.
In 'class.js':
class MyClass {
constructor(props) {
this.filename = __filename;
}
}
In 'init.js':
let obj = new MyClass();
Here, obj.filename should be './init.js' but is './class.js'
How can I get __filename to be the filename of the file the instance is created in instead of the file where the class is defined?