What does ./
mean? I assume that it is used to search a path, but I am not sure if that is true. I know that, for example, in C# if I want to search a path I can use ../../file.exe
.
Currently what I want is to run a command in node.js
from my application in NW.js
with the following code:
var exec = require('child_process').exec;
exec('node ./server.js', function(error, stdout, stderr) {
console.log('stdout: ', stdout);
console.log('stderr: ', stderr);
if (error !== null) {
console.log('exec error: ', error);
}
});
However, the code above does not produce the desired results. I believe it is because I don't know how to search the path of server.js
that I want to run.
I'm assuming you're using some form of *NIX
.
./
is your current directory. So, for example, using cd ./examplefolder
is perfectly valid.
../
is the parent directory. So, for example, you can use cd ../
to go up a level in the directory hierarchy.
~
is your home directory. So, if you're at ~/example/example2/example3
, you can use cd ~/
to return to home quickly.
If you're using nodejs, simply using the command node yourfilehere.js
will execute it, if your current directory is the one you're launching the file from. Using node ../yourfilehere.js
works just as well... but then again, so does cd ../
and node yourfilehere.js
.