Summary
New Laravel 12 applications ship an .npmrc containing ignore-scripts=true. npm reads .npmrc files upward from the working directory, so when NativePHP installs its dependencies in vendor/nativephp/desktop/resources/electron/, it inherits the application's setting and skips every package install script — including the postinstall that downloads the Electron binary.
The install reports success. node_modules/electron/ exists, but:
$ ls node_modules/electron/dist/
LICENSES.chromium.html # and nothing else
$ cat node_modules/electron/path.txt
# empty
Nothing surfaces the problem until the app is launched, and the resulting error does not mention npm, scripts, or Electron's download.
Reproducing
laravel new my-app (Laravel 12 — confirm .npmrc contains ignore-scripts=true)
composer require nativephp/desktop && php artisan native:install
php artisan native:run
Why it is hard to diagnose
Two things obscure the cause:
- The install looks clean. npm prints an
install-scripts advisory among its normal output, but exits 0 and creates node_modules/electron/, so there is no obvious failure to investigate.
- Re-running does not help.
npm install in that directory reports success and still skips the download, so the natural first instinct produces no change.
Worth noting separately: any later npm install in that directory has the same effect on an already-working install. Adding or updating a single unrelated package silently removes the Electron binary again, so an environment that worked yesterday can stop working after an unrelated change.
Environment
|
|
nativephp/desktop |
2.2.1 |
| Laravel |
12 (default skeleton, ships .npmrc) |
| npm |
11.19.0 |
| Node |
26.7.0 |
| macOS |
26.0, Apple silicon |
Possible fixes
Roughly in order of how much they'd help:
- Preflight check. Before launching, verify
node_modules/electron/path.txt is non-empty and the binary at that path exists. If not, fail with a message naming the cause and the remedy (npm install-scripts approve electron, or npm install --ignore-scripts=false). This alone converts a confusing hunt into a one-line fix.
- Install with scripts explicitly enabled. NativePHP controls its own dependency install, so it could pass
--ignore-scripts=false when installing in resources/electron/, making it immune to whatever the host application configures.
- Ship an
.npmrc in resources/electron/. A directory-local .npmrc takes precedence over ancestors, so this would isolate NativePHP's install from the application's policy.
Happy to open a PR for the preflight check if that direction seems right.
Summary
New Laravel 12 applications ship an
.npmrccontainingignore-scripts=true. npm reads.npmrcfiles upward from the working directory, so when NativePHP installs its dependencies invendor/nativephp/desktop/resources/electron/, it inherits the application's setting and skips every package install script — including thepostinstallthat downloads the Electron binary.The install reports success.
node_modules/electron/exists, but:Nothing surfaces the problem until the app is launched, and the resulting error does not mention npm, scripts, or Electron's download.
Reproducing
laravel new my-app(Laravel 12 — confirm.npmrccontainsignore-scripts=true)composer require nativephp/desktop && php artisan native:installphp artisan native:runWhy it is hard to diagnose
Two things obscure the cause:
install-scriptsadvisory among its normal output, but exits 0 and createsnode_modules/electron/, so there is no obvious failure to investigate.npm installin that directory reports success and still skips the download, so the natural first instinct produces no change.Worth noting separately: any later
npm installin that directory has the same effect on an already-working install. Adding or updating a single unrelated package silently removes the Electron binary again, so an environment that worked yesterday can stop working after an unrelated change.Environment
nativephp/desktop.npmrc)Possible fixes
Roughly in order of how much they'd help:
node_modules/electron/path.txtis non-empty and the binary at that path exists. If not, fail with a message naming the cause and the remedy (npm install-scripts approve electron, ornpm install --ignore-scripts=false). This alone converts a confusing hunt into a one-line fix.--ignore-scripts=falsewhen installing inresources/electron/, making it immune to whatever the host application configures..npmrcinresources/electron/. A directory-local.npmrctakes precedence over ancestors, so this would isolate NativePHP's install from the application's policy.Happy to open a PR for the preflight check if that direction seems right.