Hello,
With Node 16 and when "type": "module" is specified in package.json
, the function getFileName()
returns the file name with file://
prefix.
Example with the reproducible code below:
$ node index.js
Result:
file:///Users/myuser/projects/myproject/mytest/index.js
Expected result:
/Users/myuser/projects/myproject/mytest/index.js
Reproducible code:
package.json
{
"name": "mytest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"callsites": "^4.0.0"
}
}
index.js
import callsites from 'callsites';
function unicorn() {
console.log(callsites()[0].getFileName());
}
unicorn();
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too