大家好,我是MEAN堆栈中的新手。
之前我使用php进行web开发,我通常使用"shell_exec“来浏览和读取服务器json文件。
如何在均值堆栈中执行shell命令行?
MEAN堆栈中的"shell_exec“是什么?
提前感谢:)
发布于 2017-07-02 12:29:44
如果你需要浏览json -它要简单得多:
const data = require('./some-file.json');如果您仍然需要exec,可以使用以下命令:
const { exec } = require('child_process');
exec('cat *.js bad_file | wc -l', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
});https://stackoverflow.com/questions/44867421
复制相似问题