Fix Linux build and packaging for Node.js v22#225
Open
JesperGravgaard wants to merge 2 commits intonurpax:masterfrom
Open
Fix Linux build and packaging for Node.js v22#225JesperGravgaard wants to merge 2 commits intonurpax:masterfrom
JesperGravgaard wants to merge 2 commits intonurpax:masterfrom
Conversation
added 2 commits
March 8, 2026 09:37
- Replace yarn with npm/npx in start/debug scripts - Scope NODE_OPTIONS=--openssl-legacy-provider to react-scripts only (Electron rejects it if set globally) - Pass --no-sandbox to Electron (Chrome sandbox not configured on this system) - Upgrade electron-builder from v22 to v26.8.1 (v22 incompatible with Node 22) - Pin @types/ms to 0.7.34 (v2.1.0 uses TS4 template literals, project uses TS3) - Set deb as the only Linux target (AppImage requires libfuse2, not available) - Add executableArgs: [--no-sandbox] to linux build config (fixes app menu launch) - Add build-scripts/afterInstall.sh: replaces /usr/bin/petmate symlink with a wrapper script that passes --no-sandbox, so CLI launch works without flags - Update README with Linux build/run/package instructions
- Add system dependencies (fakeroot, dpkg-dev) to README - Bake NODE_OPTIONS=--openssl-legacy-provider into the build script so plain 'npm run build' works without manual env var setup - Fix hardcoded version in README install example to use a glob - Rename 'Install dependencies' section to 'Install Node dependencies'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Building and packaging Petmate as a
.debon modern Linux (Node.js v17+, Ubuntu 22.04+) is broken in several ways that together prevent the package from being built or from working correctly after installation.Solution
package.jsonelectron-builderupgraded from v22 to v26.8.1Version 22 is incompatible with Node.js 22 and fails at packaging time. v26.8.1 resolves this.
NODE_OPTIONS=--openssl-legacy-providerbaked into thebuildandstartscriptsWebpack (used internally by
react-scripts) requires this flag on Node.js v17+ due to OpenSSL API changes. However, setting it globally causes Electron itself to crash on startup with an unrecognized option error. The fix scopes it only to thereact-scriptsprocess in both scripts, sonpm run buildandnpm startwork out of the box without any manual environment setup.yarnreplaced withnpxThe
startanddebugscripts previously invokedyarn react-scripts, which fails if yarn is not installed. Replaced withnpx react-scripts, which works with npm alone.executableArgs: ["--no-sandbox"]added to linux build configOn Linux systems where the Chrome sandbox setuid binary is not configured (common in many environments), Electron refuses to start without
--no-sandbox. This flag is added toexecutableArgsso it is written into the.desktopfile, fixing launches from the application menu.deb.afterInstallpointing tobuild-scripts/afterInstall.shSee below.
@types/mspinned to0.7.34The latest version (2.1.0) uses TypeScript 4 template literal types, which are incompatible with this project's TypeScript 3 compiler. This caused the build to fail with a type error in a transitive dependency. Pinning to
0.7.34restores compatibility.build-scripts/afterInstall.shelectron-builder installs
/usr/bin/petmateas a symlink pointing at the Electron binary in/opt/Petmate/petmate. Symlinks have no mechanism to inject command-line flags, so the--no-sandboxflag fromexecutableArgsis not applied when launching from the terminal.This postinst script runs after
dpkg -iand replaces the symlink with a small shell wrapper:This ensures that running
petmatefrom the terminal works without requiring the user to manually pass any flags.README.mdAdded a Linux section documenting how to build and package Petmate as a
.deb. Covers system dependencies (fakerootanddpkg-dev, required by electron-builder to produce a.deb), installing Node dependencies, running in development mode, and packaging and installing the.deb.package-lock.jsonUpdated to reflect dependency changes.