-2

H, I am trying to install one module by scripting method but i do not know how to install that by node scripting language or if you have any idea please share with me.

if(filename==".tgz"){

//How to run this command?
"npm install --save ../test/datemodule.tgz"

}
Sitharth
  • 127
  • 1
  • 11

1 Answers1

0

You can use the child_process API.

if (filename === ".tgz") {
  const { exec } = require("child_process");
  exec("npm install --save ../test/datemodule.tgz");
}
Jack Bashford
  • 40,575
  • 10
  • 44
  • 74