我创建了一项服务,可以使用child-process
从AngularJS控制器中进行一些CLI /终端命令,但看来我无法做到这一点。以下是我的服务:
listFiles.js:
'use strict'
var exec = require('child_process').exec;
const listFiles = function(){
exec('ls',(err,stdout,stderr) => {
if (err) {
// node couldn't execute the command
return;
}
// the *entire* stdout and stderr (buffered)
console.log('stdout: ' + stdout);
console.log(stderr);
});
}
export default listFiles;
我还向我的package.json中添加了以下内容:
"browser": {
"fs": false,"child_process": false
},
我遇到以下错误:
TypeError:exec不是函数
我正在使用webpack来构建应用程序。有没有办法在AngularJS控制器中/或作为AngularJS服务进行CLI命令?