-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
  • 137
  • 2
  • 12

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
  • 43,180
  • 11
  • 50
  • 79