我正在开发一个Electron应用程序,我需要从中安装依赖项 包裹sudo-prompt最终部分起作用 我的代码:
const sudo = require("sudo-prompt");
sudo.exec("apt-get install lib32gcc1", {name: "SteamCMD GUI"}, (error, stdout, stderr) => {
// The code here doesn't execute, as it possibly waits for the user's confirmation to press Y and Enter
});
依赖永远不会安装。
如何解决? 谢谢!
答案 0 :(得分:0)
试试这样:
const sudo = require("sudo-prompt");// The -y did the trick
sudo.exec("apt-get install lib32gcc1 -y", {name: "SteamCMD GUI"}, (error, stdout, stderr) => {
// The code here doesn't execute, as it possibly waits for the user's confirmation to press Y and Enter
});
-y
选项会使apt-get
跳过提示。