如何使用nodejs执行命令行。我正在尝试使用Visual Studio代码编辑器通过--save在本地项目中在本地安装模块,但是脚本无法正常工作。有人能找到我在哪里遇到的错误吗?
答案 0 :(得分:1)
尝试使用命令连接变量,并将角度项目的路径添加到cwd
参数:
child = exec("npm install --save" + module_ins,
{
cwd: '/path_to_angular_project'
},
function (error, stdout, stderr) {
...
child = exec(`npm install --save ${module_ins}`,
{
cwd: '/path_to_angular_project'
},
function (error, stdout, stderr) {
...