Node -Webkit Child Process Exec

I want to execute homebrew command like

brew list

      

I followed the documentation and followed it like this:

child = exec('brew', function (error, stdout, stderr) {
 console.log(stdout);
 console.log(stderr);
});

      

I get the command not found error and realized that if I do / usr / local / bin / brew as a command it works. However, just using 'brew' should work, since I can run 'brew' from the command line in exactly the same way.

Why is this and what needs to be done to make make brew run as a child process in node? I feel like part of the problem because the node-webkit command seems to be executed from bin / sh.

thank

+1


source to share


1 answer


It may depend on how you start node-webkit and how you are setting up PATH

. When I start from command line it inherits environment variables from my command line including PATH

. If I start by double clicking in the gui it inherits the system (presumably /etc/paths

) and any additions I make to my .bashrc / .bash_profile have no effect.



Also, I am not a security expert, but my understanding of best practices would involve using the absolute path to the executable you are running, so it is harder to fool around setting an environment variable. To this extent, you are better off using the full path to brew

.

+1


source







All Articles