从js文件运行npm functs

时间:2018-07-26 09:28:24

标签: javascript node.js npm

如何从js文件运行npm funct

1 个答案:

答案 0 :(得分:1)

是的,您可以这样做,下面是代码:

var execSync = require('child_process').execSync;

var list = execSync('yarn list', { encoding: 'utf-8' });
console.log(list);