Reputation: 173
I have two scripts: the first requiring the second.
1st script main.js:
...
var a = require(second);
...
2d. script second.js
path = path/of/the/main/script
I want to get access to the path of the first script within the second script without passing it as argument. Is it a way to achieve it?
Upvotes: 0
Views: 48
Reputation: 3081
module.parent.filename
holds the file name of the calling script. See here for more information.
Upvotes: 1