Skip to content

Command failed: 'npm run dev' (exit code 1) in Starting NativePHP dev server… for desktop #125

Description

@MohamedBashandy7

What were you trying to do?

I was trying to set up a new Laravel Desktop project, but when I reached the step where I run the application for the first time, it throws an execution error.

PS D:\Black Pearl\Back End\accounting> php artisan native:run

  Starting NativePHP dev server…

 Fetching latest dependencies…

 Installing NPM dependencies (This may take a while)...

 Installing NPM dependencies using the npm package manager...


 Starting NativePHP app

 Running the dev script with npm...


 Command failed: 'npm run dev' (exit code 1)

To confirm the issue, it had indeed been installed correctly beforehand.

PS D:\Black Pearl\Back End\accounting> composer require nativephp/desktop
./composer.json has been updated
Running composer update nativephp/desktop
Loading composer repositories with package information
Updating dependencies
Lock file operations: 4 installs, 0 updates, 0 removals
  - Locking nativephp/desktop (2.2.1)
  - Locking nativephp/php-bin (1.2.0)
  - Locking spatie/laravel-package-tools (1.93.1)
  - Locking symfony/filesystem (v8.1.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals
  - Downloading symfony/filesystem (v8.1.0)
  - Installing symfony/filesystem (v8.1.0): Extracting archive
  - Installing spatie/laravel-package-tools (1.93.1): Extracting archive
  - Installing nativephp/php-bin (1.2.0): Extracting archive
  - Installing nativephp/desktop (2.2.1): Extracting archive
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   INFO  Discovering packages.

  inertiajs/inertia-laravel ................................................................................................................. DONE
  laravel/fortify ........................................................................................................................... DONE
  laravel/pail .............................................................................................................................. DONE
  laravel/pao ............................................................................................................................... DONE
  laravel/passkeys .......................................................................................................................... DONE
  laravel/sail .............................................................................................................................. DONE
  laravel/tinker ............................................................................................................................ DONE
  laravel/wayfinder ......................................................................................................................... DONE
  nativephp/desktop ......................................................................................................................... DONE
  nesbot/carbon ............................................................................................................................. DONE
  nunomaduro/collision ...................................................................................................................... DONE
  nunomaduro/termwind ....................................................................................................................... DONE

93 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force

   INFO  No publishable resources for tag [laravel-assets].

No security vulnerability advisories found.
Using version ^2.2 for nativephp/desktop
PS D:\Black Pearl\Back End\accounting> php artisan native:install

  Would you like to publish the Electron project? (yes/no) [no]
❯ yes

  Would you like to install the NativePHP NPM dependencies? (yes/no) [yes]
❯ yes

 Installing NPM dependencies (This may take a while)...

 Installing NPM dependencies using the npm package manager...


  Creating Electron project

 Created Electron project in `./nativephp/electron`

  Installing composer scripts

 Installing `composer native:dev` script alias...

 native:dev script installed!

 Installing `native:install --publish` post-update-cmd script

 post-update-cmd script installed!

  Publishing NativePHP Service Provider...

   INFO  Publishing [nativephp-provider] assets.

  Copying file [D:\Black Pearl\Back End\accounting\vendor\nativephp\desktop\resources\stubs\NativeAppServiceProvider.php.stub] to [D:\Black Pearl\Back End\accounting\app\Providers\NativeAppServiceProvider.php]  DONE

   INFO  Publishing [nativephp-config] assets.

  Copying file [D:\Black Pearl\Back End\accounting\vendor\nativephp\desktop\config\nativephp.php] to [D:\Black Pearl\Back End\accounting\config\nativephp.php]  DONE

  Would you like to start the NativePHP development server: (yes/no) [no]
❯ yes

  Starting NativePHP dev server…

 Fetching latest dependencies…

 Installing NPM dependencies (This may take a while)...

 Installing NPM dependencies using the npm package manager...


 Starting NativePHP app

 Running the dev script with npm...


 Command failed: 'npm run dev' (exit code 1)

PS D:\Black Pearl\Back End\accounting>

What happened?

When I initially attempt to solve the problem regarding the electron, the following appears:

PS D:\Black Pearl\Back End\accounting\nativephp\electron> npm run dev

> nativephp@2.0.0 dev
> cross-env node php.js && electron-vite dev --watch

node:path:513
      validateString(arg, 'path');
      ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at join (node:path:513:7)
    at file:///D:/Black%20Pearl/Back%20End/accounting/nativephp/electron/php.js:52:22
    at ModuleJob.run (node:internal/modules/esm/module_job:447:25)
    at async node:internal/modules/esm/loader:646:26
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v26.4.0
PS D:\Black Pearl\Back End\accounting\nativephp\electron>

, for a clearer view of the problem


PS D:\Black Pearl\Back End\accounting> php artisan native:run -vvv

  Starting NativePHP dev server…

 Fetching latest dependencies…

 Installing NPM dependencies (This may take a while)...

 Installing NPM dependencies using the npm package manager...


> nativephp@2.0.0 postinstall
> node ./node_modules/electron-builder/cli.js install-app-deps

  • electron-builder  version=26.8.1
  • executing @electron/rebuild  electronVersion=38.5.0 arch=x64 buildFromSource=false workspaceRoot=D:\Black Pearl\Back End\accounting\nativephp\electron projectDir=./ appDir=./
  • installing native dependencies  arch=x64
  • completed installing native dependencies

up to date, audited 962 packages in 19s

204 packages are looking for funding
  run `npm fund` for details

29 vulnerabilities (2 low, 8 moderate, 17 high, 2 critical)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
npm warn allow-scripts 4 packages have install scripts not yet covered by allowScripts:
npm warn allow-scripts   electron@38.5.0 (postinstall: node install.js)
npm warn allow-scripts   electron-chromedriver@38.4.0 (install: node ./download-chromedriver.js)
npm warn allow-scripts   electron-winstaller@5.4.0 (install: node ./script/select-7z-arch.js)
npm warn allow-scripts   esbuild@0.25.12 (postinstall: node install.js)
npm warn allow-scripts
npm warn allow-scripts Run `npm approve-scripts --allow-scripts-pending` to review, or `npm approve-scripts <pkg>` to allow.

 Starting NativePHP app

 Running the dev script with npm...


> nativephp@2.0.0 dev
> cross-env node php.js && electron-vite dev --watch

Binary Source:  D:\Black Pearl\Back End\accounting\vendor\nativephp\php-bin\bin\win\x64\php-8.4.zip
Binary Filename:  php.exe
PHP version: 8.4
Unzipping PHP binary from D:\Black Pearl\Back End\accounting\vendor\nativephp\php-bin\bin\win\x64\php-8.4.zip to D:\Black Pearl\Back End\accounting\vendor\nativephp\desktop\resources\build\php
vite v7.1.12 building SSR bundle for development...

watching for file changes...

build started...
renderer and preload config is missing
transforming...
✓ 37 modules transformed.
rendering chunks...
out/main/index.js  90.15 kB
built in 1000ms.

build the electron main process successfully
error during start dev server and electron app:
Error: Electron uninstall
    at getElectronPath (file:///D:/Black%20Pearl/Back%20End/accounting/nativephp/electron/node_modules/electron-vite/dist/chunks/lib-ClgyQuZx.js:132:19)
    at startElectron (file:///D:/Black%20Pearl/Back%20End/accounting/nativephp/electron/node_modules/electron-vite/dist/chunks/lib-ClgyQuZx.js:205:26)
    at createServer (file:///D:/Black%20Pearl/Back%20End/accounting/nativephp/electron/node_modules/electron-vite/dist/chunks/lib-B4dCEySN.js:74:14)
    at async CAC.<anonymous> (file:///D:/Black%20Pearl/Back%20End/accounting/nativephp/electron/node_modules/electron-vite/dist/cli.js:67:9)

 Command failed: 'npm run dev' (exit code 1)

PS D:\Black Pearl\Back End\accounting

How to reproduce the bug

I think you may solve the problem cause I can't

Debug Output

PS D:\Black Pearl\Back End\accounting\nativephp\electron> npm run dev

> nativephp@2.0.0 dev
> cross-env node php.js && electron-vite dev --watch

node:path:513
      validateString(arg, 'path');
      ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at join (node:path:513:7)
    at file:///D:/Black%20Pearl/Back%20End/accounting/nativephp/electron/php.js:52:22
    at ModuleJob.run (node:internal/modules/esm/module_job:447:25)
    at async node:internal/modules/esm/loader:646:26
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v26.4.0
PS D:\Black Pearl\Back End\accounting\nativephp\electron>

, for a clearer view of the problem


PS D:\Black Pearl\Back End\accounting> php artisan native:run -vvv

  Starting NativePHP dev server…

 Fetching latest dependencies…

 Installing NPM dependencies (This may take a while)...

 Installing NPM dependencies using the npm package manager...


> nativephp@2.0.0 postinstall
> node ./node_modules/electron-builder/cli.js install-app-deps

  • electron-builder  version=26.8.1
  • executing @electron/rebuild  electronVersion=38.5.0 arch=x64 buildFromSource=false workspaceRoot=D:\Black Pearl\Back End\accounting\nativephp\electron projectDir=./ appDir=./
  • installing native dependencies  arch=x64
  • completed installing native dependencies

up to date, audited 962 packages in 19s

204 packages are looking for funding
  run `npm fund` for details

29 vulnerabilities (2 low, 8 moderate, 17 high, 2 critical)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
npm warn allow-scripts 4 packages have install scripts not yet covered by allowScripts:
npm warn allow-scripts   electron@38.5.0 (postinstall: node install.js)
npm warn allow-scripts   electron-chromedriver@38.4.0 (install: node ./download-chromedriver.js)
npm warn allow-scripts   electron-winstaller@5.4.0 (install: node ./script/select-7z-arch.js)
npm warn allow-scripts   esbuild@0.25.12 (postinstall: node install.js)
npm warn allow-scripts
npm warn allow-scripts Run `npm approve-scripts --allow-scripts-pending` to review, or `npm approve-scripts <pkg>` to allow.

 Starting NativePHP app

 Running the dev script with npm...


> nativephp@2.0.0 dev
> cross-env node php.js && electron-vite dev --watch

Binary Source:  D:\Black Pearl\Back End\accounting\vendor\nativephp\php-bin\bin\win\x64\php-8.4.zip
Binary Filename:  php.exe
PHP version: 8.4
Unzipping PHP binary from D:\Black Pearl\Back End\accounting\vendor\nativephp\php-bin\bin\win\x64\php-8.4.zip to D:\Black Pearl\Back End\accounting\vendor\nativephp\desktop\resources\build\php
vite v7.1.12 building SSR bundle for development...

watching for file changes...

build started...
renderer and preload config is missing
transforming...
✓ 37 modules transformed.
rendering chunks...
out/main/index.js  90.15 kB
built in 1000ms.

build the electron main process successfully
error during start dev server and electron app:
Error: Electron uninstall
    at getElectronPath (file:///D:/Black%20Pearl/Back%20End/accounting/nativephp/electron/node_modules/electron-vite/dist/chunks/lib-ClgyQuZx.js:132:19)
    at startElectron (file:///D:/Black%20Pearl/Back%20End/accounting/nativephp/electron/node_modules/electron-vite/dist/chunks/lib-ClgyQuZx.js:205:26)
    at createServer (file:///D:/Black%20Pearl/Back%20End/accounting/nativephp/electron/node_modules/electron-vite/dist/chunks/lib-B4dCEySN.js:74:14)
    at async CAC.<anonymous> (file:///D:/Black%20Pearl/Back%20End/accounting/nativephp/electron/node_modules/electron-vite/dist/cli.js:67:9)

 Command failed: 'npm run dev' (exit code 1)

PS D:\Black Pearl\Back End\accounting

Which operating systems have you seen this occur on?

No response

Notes

Please clarify and resolve the issue quickly, as I cannot create my own application under these circumstances.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions