在Linux上使用Electron安装依赖项

时间:2017-10-05 22:42:56

标签: javascript linux electron sudo

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

依赖永远不会安装。

如何解决? 谢谢!

1 个答案:

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