Reputation: 310
I applied the code underneath in my NodeJs application:
console.log(__dirname);
I wish to pack the application using pkg. However, where normally the path to the .js file would have been printed (let's assume it is "F:\Files\apps\my_dir", I now only get a "F:\snapshot\my_dir" (the middle part has been replaced by "snapshot". How can I fix that?
Upvotes: 3
Views: 1411
Reputation: 310
I finally worked out the problem. We should not be using __dirname. Instead, we should do it like this:
const process = require('process');
console.log(process.cwd())
Upvotes: 2