我一直在嘗試使用 Electron 將我的 Angular 8 應(yīng)用程序?qū)С龅阶烂鎽?yīng)用程序。我想出了如何使用 Electron 運行它,但是當(dāng)我決定使用電子打包器時,我遇到了錯誤。我得到的錯誤與找不到“app-root-path”有關(guān)。我正在使用 main.ts 并將其轉(zhuǎn)換為 Electron 使用的 main.js。任何幫助,將不勝感激。主文件import { app, BrowserWindow } from 'electron';import { resolve } from 'app-root-path';// Keep a global reference of the window object, if you don't, the window will// be closed automatically when the JavaScript object is garbage collected.let win: BrowserWindow;function createWindow () { // Create the browser window. win = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: true, }, }); // Load the angular app. // Make sure that this path targets the index.html of the // angular application (the distribution). win.loadFile(resolve('dist/Invoices/index.html')); // Emitted when the window is closed. win.on('closed', () => { // Dereference the window object, usually you would store windows // in an array if your app supports multi windows, this is the time // when you should delete the corresponding element. win = null; });}// This method will be called when Electron has finished// initialization and is ready to create browser windows.// Some APIs can only be used after this event occurs.app.on('ready', createWindow);// Quit when all windows are closed.app.on('window-all-closed', () => { // On macOS it is common for applications and their menu bar // to stay active until the user quits explicitly with Cmd + Q if (process.platform !== 'darwin') { app.quit(); }});每當(dāng)我編譯應(yīng)用程序并且 Electron-packager 創(chuàng)建 exe 時,我都會單擊它,但我收到相同的錯誤?!癑avascript錯誤:錯誤:找不到模塊'app-root-path'需要堆棧:/Invoices/Invoices electron app-darwin-x64/Invoices electron app.app/Contents/Resources/app/bin/main.js”唯一我遇到的另一個問題是必須將 tsconfig.json 目標(biāo)設(shè)置為“es5”,然后在嘗試使用 Electron-packager 時遇到了這個問題。
為什么我的 Angular 8 應(yīng)用程序沒有使用 Electron Packager
寶慕林4294392
2021-09-30 17:06:38