在 Mac 中打開 Electron 應用程序時出錯:“file:///Applications/../Contents/Resources/app.asar/dist/index.html” (Error in Opening Electron App in Mac:"file:///Applications/../Contents/Resources/app.asar/dist/index.html")


問題描述

在 Mac 中打開 Electron 應用程序時出錯:“file:///Applications/../Contents/Resources/app.asar/dist/index.html” (Error in Opening Electron App in Mac:"file:///Applications/../Contents/Resources/app.asar/dist/index.html")

我已經為 mac 構建了電子應用程序,但是當我運行它時,它給出了以下錯誤

“不允許加載本地資源:file:///Applications/e‑admin.app /Contents/Resources/app.asar/dist/index.html"。

這是我做的步驟。

1) electron‑builder build ‑‑mac 它創建了以下文件是 dist 文件夾。a) e‑admin‑0.0.0.dmg , e‑admin‑0.0.0‑mac.zip,index.html 和一個 mac 文件夾 b) 在 mac 文件夾中我可以看到 mac/e‑admin.app/Contents/Resources /app.asar 文件(不是文件夾)

2)我雙擊並安裝了 e‑admin‑0.0.0.dmg 並移至應用程序文件夾。3) 打開應用程序。

我必須對 app.asar 文件做任何事情嗎?(解壓縮或做一些事情?)或任何其他程序才能使其工作?

我的包.json


參考解法

方法 1:

After muiltple trial and error, The following changes worked for me

1) index.html

`<base href="/">` 

to

<base href="./">

2) in main.ts, change the directory name dist to something else

from :

win.loadURL(url.format({
  pathname: path.join(__dirname, 'dist/index.html'),     
  protocol: 'file:',
  slashes: true
}));

To:

win.loadURL(url.format({
  pathname: path.join(__dirname, 'angular_build/index.html'),     
  protocol: 'file:',
  slashes: true
}));

3) Angular.js

"outputPath": "dist/",

to

"outputPath": "angular_build/",

Although I have seen suggesions to change step 2 & 3 , I was quite skepitcal. Looks like dist directlory some how does not work and have to change to some thing like as mentioned above

(by Raghu VallikkatRaghu Vallikkat)

參考文件

  1. Error in Opening Electron App in Mac:"file:///Applications/../Contents/Resources/app.asar/dist/index.html" (CC BY‑SA 2.5/3.0/4.0)

#electron-builder #electron #macos






相關問題

Electron Builder 代碼簽名下載證書錯誤 (Electron Builder Code Signing Download Certificate Error)

Electron 使用 electron-builder 創建 MSI 安裝程序 (Electron create MSI installer using electron-builder)

如何使用電子/電子生成器創建發布通道? (How to create release channels with electron/electron-builder?)

electron-builder,如何設置節點環境變量 (electron-builder, how to set node environmental variables)

電子應用Mac應用商店圖標問題->“缺少必需的圖標” (electron app Mac app store icon issue -> "missing required icon")

帶有 Vue 和 vue-cli-plugin-electron-builder 的電子應用程序無法與 Tesseract.js 一起使用 (Electron App with Vue and vue-cli-plugin-electron-builder can't working with Tesseract.js)

使用 Electron-builder 自定義 NSIS 安裝程序 (Customize NSIS installer with Electron-builder)

在 Mac 中打開 Electron 應用程序時出錯:“file:///Applications/../Contents/Resources/app.asar/dist/index.html” (Error in Opening Electron App in Mac:"file:///Applications/../Contents/Resources/app.asar/dist/index.html")

Mac Os 10.11.6 中 Windows 的 Electron Pakaging 問題 (Electron Pakaging issue for Windows in Mac Os 10.11.6)

對於 Mac,是否有關於基於電子的應用程序卸載的事件?還是一種區分安裝和更新的方法? (Is there an event on electron based app's uninstall, for Mac? Or a way to distinguish between an install and an update?)

Electron 應用架構 - IPC 與 API (Electron application architecture - IPC vs API)

公證問題:altool 不在 PATH 中? (Notarize issue: altool not in PATH?)







留言討論