【发布时间】:2019-12-09 19:38:15
【问题描述】:
H, 我正在尝试通过脚本方法安装一个模块,但我不知道如何通过节点脚本语言安装它,或者如果您有任何想法,请与我分享。
if(filename==".tgz"){
//How to run this command?
"npm install --save ../test/datemodule.tgz"
}
【问题讨论】:
标签: javascript node.js
H, 我正在尝试通过脚本方法安装一个模块,但我不知道如何通过节点脚本语言安装它,或者如果您有任何想法,请与我分享。
if(filename==".tgz"){
//How to run this command?
"npm install --save ../test/datemodule.tgz"
}
【问题讨论】:
标签: javascript node.js
您可以使用child_process API。
if (filename === ".tgz") {
const { exec } = require("child_process");
exec("npm install --save ../test/datemodule.tgz");
}
【讨论】: