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 .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 # emptyNothing surfaces the problem until the app is launched, and the resulting error does not mention npm, scripts, or Electron's download.
Reproducing
Why it is hard to diagnose
Two things obscure the cause:
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
Possible fixes
Roughly in order of how much they'd help:
Happy to open a PR for the preflight check if that direction seems right.