Electron builds require electron and electron-builder as dependencies, but these pollute your development environment and can interfere with your regular npm start and start.bat scripts.
This build pipeline keeps your development environment completely clean by:
- Installing your main app dependencies (Express, SQLite, etc.)
- Temporarily switching to a build-specific
package.json - Building the Electron app with isolated build dependencies
- Restoring your clean development environment automatically
package.json- Your clean development dependencies (no Electron)package-build.json- Build configuration with Electron dependenciesbuild-electron.bat- Windows build scriptbuild-electron.sh- Linux/Mac build scriptbuild-electron.ps1- Original PowerShell script (backup)
build-electron.bat./build-electron.shNote: The script will build a native app for your platform (Linux AppImage/dir or Mac .app)
# Install main dependencies
npm install
# Temporarily switch to build config
copy package-build.json package.json
# Install build deps and build
npm install electron electron-builder --save-dev
npm run build
# Restore clean environment
git checkout package.json
npm install- Installs your main app dependencies normally
- Backs up your original
package.json - Copies
package-build.jsonoverpackage.json(contains Electron config) - Installs Electron build dependencies
- Builds the Electron app
- Restores your original
package.json - Reinstalls clean dependencies
✅ Clean Dev Environment: Your main package.json never gets Electron dependencies
✅ Works in Fresh Clones: No setup required, works immediately
✅ Reliable Dev Scripts: npm start and start.bat always work
✅ Simple: No complex directory structures or path issues
✅ Automatic Cleanup: Restores your environment automatically
Built app will be in: dist-electron/win-unpacked/SimpleChatJS.exe
If something goes wrong:
- The script will automatically restore your
package.jsonfrom backup - Delete
node_modulesand runnpm installto reset - Your development environment should be clean again