When I build my app, 'fs' module doesn't work. So, it must write file, but when I start my app nothing happens. But if I start my app with:
$ /path/to/app nw
It works correctly. What's wrong?
Some code, where I use fs:
function check_prob_2(){
console.log('Problem 2');
fs.appendFile('log.txt', 'Checking problem 2: \n\n');
...
}
I use that function, but it doesn't work. It doesn't work only after build application. I build it with this guide
Try this:
Include the following (standard) module:
Specify the path as follows:
More info on the __dirname global can be found here.
EDIT
Since __dirname is not defined in node-webkit, you'll have to use the following workaround:
Make a file
util.js
or however you want to call it, containing this line:The __dirname variable can now be exposed in your main file:
And replace
__dirname
bydirname
in the code.Details here