FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Laravel 12's default .npmrc silently prevents the Electron binary from downloading · Issue #145 · NativePHP/desktop · GitHub

Laravel 12's default .npmrc silently prevents the Electron binary from downloading #145

Description

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

  1. laravel new my-app (Laravel 12 — confirm .npmrc contains ignore-scripts=true)
  2. composer require nativephp/desktop && php artisan native:install
  3. php artisan native:run

Why it is hard to diagnose

Two things obscure the cause:

  1. 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.
  2. 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:

  1. 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.
  2. 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.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL