在 Linux 上使用 Electron 安装依赖项

Install a dependency using Electron on Linux

我正在开发一个 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 
});

并且永远不会安装依赖项。

如何解决?
谢谢!

试试这样:

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 跳过提示。