function Start() { const exec = require('child_process').exec; exec("node -v", (error, stdout, stderr) => { if (error) { alert(`exec error: ${error}`); return; } alert(`stdout: ${stdout}`); alert(`stderr: ${stderr}`); });} 

As a result, the command "node" was not found. :( I do it all in nw.js (NodeWebkit)

  • and the node itself is worth it? - DimenSi
  • :) Of course!) The answer is described below - BigTows

2 answers 2

Found a solution. You need to specify the full path to the node.

 function Start() { const exec = require('child_process').exec; exec("/usr/local/bin/node -v", (error, stdout, stderr) => { if (error) { alert(`exec error: ${error}`); return; } alert(`stdout: ${stdout}`); alert(`stderr: ${stderr}`); });} 

The solution is only suitable for OSX or MacOS. And if the user changed the standard Node.js path during installation, then this method will not work.

    Specify the full path for the Node:

     /path/to/node-webkit/nw