2017-10-05 126 views
2

我正在開發一個Electron應用程序,我需要從中安裝依賴項。
sudo-prompt結束了部分工作。
我的代碼:在Linux上使用Electron安裝依賴項

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

試試這樣說:

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