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?
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())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With