Reputation: 137
How to execute a command line using nodejs. I am trying to install a module in local by --save in my angular project using visual studio code editor but the script is not working.Anyone can find the mistake where i did?
Upvotes: 2
Views: 2066
Reputation: 12954
Try to concatenate your variable with the command and add the path of your angular project to the cwd
argument:
child = exec("npm install --save" + module_ins,
{
cwd: '/path_to_angular_project'
},
function (error, stdout, stderr) {
...
Or using Template literals:
child = exec(`npm install --save ${module_ins}`,
{
cwd: '/path_to_angular_project'
},
function (error, stdout, stderr) {
...
Upvotes: 1