New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting the current directory #5618
Comments
const path = require('path');
console.log(path.dirname(process.execPath)); Also, there exists |
Thank you very much Cosmo! The directory I get is: |
Afaik these are the only information about packaging: http://docs.nwjs.io/en/latest/For%20Users/Package%20and%20Distribute/ |
Yes, that is where I got my info from. It looks as if this book has quite a bit of packaging info: |
Struggling to find the current directory when I create an executable.
I have created a Mac server application with a mix of html and Javascript and a lot of node.js module usage. I have two xml files that the server accesses and that reside in the same folder as the application.
When I run the application as follows:
./nwjs.app/Contents/MacOS/nwjs .
and find the current directory as follows:
var workingFolder = process.cwd();
then my working folder is the one where the application and xml files reside.
However, if I follow the 'package and distribute' guidelines (create a .nw file, name it app.nw, and put in contents/resources), and then run the .app executable, I get the following as the working folder:
/private/var/folders/3x/2hq40kzs59q8gj6yfn4ktj940000gn/T/.io.nwjs.nw.HcwnF2
I assume that the context changed. So I have been looking at alternatives to get the current directory. I tried:
var workingFolder = global.__dirname;
and got the same result. Then:
var workingFolder = process.env.PWD;
and got undefined (although this worked for the 'unpackaged' version)
How do I get the current directory?
Any ideas would be much appreciated!
The text was updated successfully, but these errors were encountered: