开启子进程
// npm run dev
var ps = require('child_process').spawn("npm", ['run','dev'], {
stdio: 'inherit',
shell: true
});
ps.on('error', function(err) {
console.log(err);
});
ps.on('exit', function (err) {
console.log('exit');
});
接受用户输入
const readline = require('readline')
const rl = readline.createInterface({
input:process.stdin,
output:process.stdout
})
rl.question('你输入一句话试试?',(answer) => {
console.log('你说的话是:'+ anwser)
rl.close()
})