Electron apps with spaces in their names were loading with a blank white screen, while throwing console errors saying that it could't find the files within the packaged app.
An example error message that was being thrown.
Not allowed to load local resource: file:///Users/manovotny/Developer/electron-next-skeleton/dist/mac/Electron%20Next.app/Contents/Resources/app.asar/renderer/out/start/index.html
Specifically notice the %20 in the app name. This made Electron very unhappy.
The fix was to decode the path name, which made Electron happy again and the app files were able to load properly.
Change productName in package.json from ElectronNext to Electron Next
Run npm run dist
Double click dist/mac/Electron Next.app to open the app
Notice it loads a blank white page and there is an error in the console (might need to install electron-debug to see console error)
I also narrowed down the problem to electron-next by verify that electron-packager and electron-builder can handle spaces in app names by using the following steps.
Download the minimalistic electron-quick-start project, initialize it, and test that it works.
git clone git@github.com:electron/electron-quick-start.git
cd electron-quick-start
npm i
npm start
Install electron-packager and / or electron-builder which wraps ASAR.
npm i electron-packager
Add a productName, with spaces, to package.json.
"productName": "Electron Quick Start"
Add dist script by adding the following to scripts in package.json.
"dist": "electron-packager . --out dist"
Run the dist script.
npm run dist
Double click the Electron Quick Start.app app in the generated dist directory and notice that the app loads / runs without errors.
Description
Electron apps with spaces in their names were loading with a blank white screen, while throwing console errors saying that it could't find the files within the packaged app.
An example error message that was being thrown.
Specifically notice the
%20
in the app name. This made Electron very unhappy.The fix was to decode the path name, which made Electron happy again and the app files were able to load properly.
Steps to Reproduce Error
productName
inpackage.json
fromElectronNext
toElectron Next
npm run dist
dist/mac/Electron Next.app
to open the appI also narrowed down the problem to
electron-next
by verify that electron-packager and electron-builder can handle spaces in app names by using the following steps.electron-packager
and / orelectron-builder
which wraps ASAR.productName
, with spaces, topackage.json
.dist
script by adding the following toscripts
inpackage.json
.dist
script.Electron Quick Start.app
app in the generateddist
directory and notice that the app loads / runs without errors.Testing
I have tested this locally by using
npm link
with electron-next-skeleton and with thewith-electron
example innext.js
, though I wound't mind some additional verification by a second set of eyes. 👀