Silve2611 Silve2611 - 3 months ago 18
Node.js Question

Open Directory in Node.js and node-webkit

I have a function that should open a directory after it was created,

var fs = require('fs');
var open = fs.opensync(newPath, 'r');
}, 2500);

But this doesn't seem to work. I am getting the following errors

first is,

TypeError: undefined is not a function
at eval (eval at
(file:///Users/proslav/Library/Developer/Xcode/DerivedData/trackingCore-ecxfviftqracjxhimcuhhhvyddso/Build/Products/Debug/, :43:18)

and second is,

Uncaught ReferenceError: require is not defined

I was thinking that it could be that my variable
is undefinded but the log shows me the right link.
The creation of the directory with
var fs = require('fs');
works fine.

What am I doing wrong here?


I found out how it has to be done. Node-webkit offers a function for that. It is working on MAC and should also work on windows. The function below is an example function. nw.gui and gui.Shell.showItemInFolder did the thing for me. Thx for the input.

Open Folder
function openFolder(path){
    var gui = require('nw.gui');