I have the following PHP code that runs when a user clicks a button on a local intranet page to run some Node JS commands. eg.
exec('npm install', $output);
$output = implode(PHP_EOL, $output);
echo $output;
But the command doesn't seem to start ... This happens if I find the command on the command line and run it ...
I don't see any errors, and NodeJS is set as a system variable in the way, so it should know what grunts are ... Any ideas? Other teams, for example. whoami is working fine.
Any ideas?
I am on Windows 7.
Update: based on the comments below, I can now get the error message:
exec('npm install 2>&1', $output, $returnCode);
$output = implode(PHP_EOL, $output);
echo $output . ' ' . $returnCode;
And this is a mistake:
TypeError: Cannot call method 'get' of undefined at C:\Program Files (x86)\nodejs\node_modules\npm\lib\npm.js:310:23 at C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npmconf\npmconf.js:80:7 at Array.forEach (native) at C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npmconf\npmconf.js:79:13 at f (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\once\once.js:16:25) at C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npmconf\npmconf.js:108:14 at Conf. (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npmconf\npmconf.js:179:14) at Conf.next (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npmconf\lib\load-prefix.js:48:20) at C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\mkdirp\index.js:37:53 at Object.oncomplete (fs.js:107:15) C:\Program Files (x86)\nodejs\node_modules\npm\lib\npm.js:33 throw new Error('npm.load() required') ^ Error: npm.load() required at Object.npm.config.get (C:\Program Files (x86)\nodejs\node_modules\npm\lib\npm.js:33:11) at exit (C:\Program Files (x86)\nodejs\node_modules\npm\lib\utils\error-handler.js:49:27) at process.errorHandler (C:\Program Files (x86)\nodejs\node_modules\npm\lib\utils\error-handler.js:316:3) at process.emit (events.js:95:17) at process._fatalException (node.js:272:26) 7
So, it looks like PHP knows where NodeJS and NPM are ... but can't run it?
If I do whoamiin PHP, I get:nt authority\iusr
, : dom\cameron
, , PHP , ...