Unable to execute a node module within PHP
After installing the necessary modules, the following command
azure account -help
works as expected. However, when I invoke the same command from inside PHP using exec().
exec('azure account -help',$output,$responseCode)
and print the output, I get
$output: [] (empty array) and $responseCode: 8
I've tried executing the module using the command 'node'. Ex
node /usr/lib/node_modules/azure-cli/bin/azure.js account -help
This also works on command line but not through PHP's exec.
Edit: Redirecting the stderr with the following command:
exec('azure account -help &2>1',$output,$responseCode)
gives these details:
,E === undefined) && (process.env.HOMEDRIVE === undefined))) {throw new Error(, ^,Error: HOME not found, unable to store Streamline callback cache, at Object. (/usr/local/lib/node_modules/azure-cli/node_modules/streamline/lib/compiler/compile.js:278:90), at Module._compile (module.js:456:26), at Object.Module._extensions..js (module.js:474:10), at Module.load (module.js:356:32), at Function.Module._load (module.js:312:12), at Module.require (module.js:364:17), at require (module.js:380:17), at Object. (/usr/local/lib/node_modules/azure-cli/node_modules/streamline/lib/compiler/register.js:28:15), at Module._compile (module.js:456:26), at Object.Module._extensions..js (module.js:474:10)
What can I try to debug this further?
The problem was solved by invoking exec() and providing a HOME env variable:
exec('HOME=/tmp/ azure account -help 2>&1');
链接地址: http://www.djcxy.com/p/33024.html上一篇: ExpressJS Multer文件保护
下一篇: 无法在PHP中执行节点模块