Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: php artisan native:serve requires yarn? #7

Closed
mraheelkhan opened this issue Jul 20, 2023 · 19 comments
Closed

[Bug]: php artisan native:serve requires yarn? #7

mraheelkhan opened this issue Jul 20, 2023 · 19 comments
Labels
bug Something isn't working

Comments

@mraheelkhan
Copy link

mraheelkhan commented Jul 20, 2023

What happened?

Unable to serve NativePhp server via php artisan native:serve.
I am running MacOS and Laravel Valet.

How to reproduce the bug

  1. Installed Laravel.
  2. Installed NativePhp via composer
  3. Installed NativePhp via php artisan native:install
  4. Would you like to install the NativePHP NPM dependencies? (yes/no) [yes]:

yes

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

yes
and output is

Starting NativePHP dev server…
Fetching latest dependencies…
Starting NativePHP app…
sh: yarn: command not found
NativePHP scaffolding installed successfully.

Also running php artisan native:serve
Results in same output.

Package Version

Alpha Laracon release

PHP Version

8.1.19

Laravel Version

10.15.0

Which operating systems does with happen with?

macOS

Notes

Do I need to explicitly install and configure yarn for NativePhp?

Eagerly waiting to give it a try.
A lots of Love.

@mraheelkhan mraheelkhan added the bug Something isn't working label Jul 20, 2023
@Nielson
Copy link

Nielson commented Jul 20, 2023

I can confirm the same here. Latest MacOS, Macbook Air M1 running PHP through Herd.

@mraheelkhan
Copy link
Author

You need to enable corepack for node via running corepack enable in terminal.

If you are Node.js ^16.17 or >=18.6
corepack prepare yarn@stable --activate

I was able to run basic application after enabling corepack.

@blessedjasonmwanza
Copy link

I can confirm the same. Yarn is run when starting NativePHP App. It has to be added to the documentation as a requirement.

@joebenson
Copy link

Another confirmation here that Yarn seems to be required 👍

@raulillana
Copy link

+1

@Nielson
Copy link

Nielson commented Jul 21, 2023

You need to enable corepack for node via running corepack enable in terminal.

If you are Node.js ^16.17 or >=18.6 corepack prepare yarn@stable --activate

I was able to run basic application after enabling corepack.

This did it for me, however now i'm running in to this issue #16, so i'll move on from this thread :)

Thanks, @mraheelkhan !

@Thihasoehlaing
Copy link

You need to enable corepack for node via running corepack enable in terminal.

If you are Node.js ^16.17 or >=18.6 corepack prepare yarn@stable --activate

I was able to run basic application after enabling corepack.

That work for me. It is running now. But when native:install and native:serve, that only published NativeAppServiceProvider. I don't even get config file.

@Amorfx
Copy link

Amorfx commented Jul 21, 2023

In the command indeed they use yarn but I wonder if it's not just an error since for the install they use npm.

Process::path(__DIR__.'/../../resources/js/')
            ->env([
                'APP_PATH' => base_path(),
                'NATIVEPHP_PHP_BINARY_PATH' => base_path('vendor/nativephp/php-bin/bin/mac'),
                'NATIVEPHP_CERTIFICATE_FILE_PATH' => base_path('vendor/nativephp/php-bin/cacert.pem'),
                'NATIVE_PHP_SKIP_QUEUE' => $this->option('no-queue') ? true : false,
            ])
            ->forever()
            ->tty()
            ->run('yarn run dev', function (string $type, string $output) {
                if ($this->getOutput()->isVerbose()) {
                    echo $output;
                }
            });

@mraheelkhan
Copy link
Author

@Amorfx , I found that last night and wanted to change yarn run dev into npm run dev to see the output.

@Amorfx
Copy link

Amorfx commented Jul 21, 2023

@mraheelkhan I tried and then came across the issue : #27

@galamz
Copy link

galamz commented Jul 21, 2023

I can confirm the same here. Latest MacOS, Macbook Air M1 running PHP through Herd.

+1

@irsyadadl
Copy link

I have yarn installed. But when I try to run native:serve. It comes with errors.

error during start dev server and electron app:
Error: No electron app entry file found: /Users/irsyadadl/sites/desktop/vendor/nativephp/electron/resources/js/out/main/index.js
    at ensureElectronEntryFile (/Users/irsyadadl/sites/desktop/vendor/nativephp/electron/resources/js/node_modules/electron-vite/dist/chunks/lib-3592fc5a.js:26:23)
    at Object.startElectron (/Users/irsyadadl/sites/desktop/vendor/nativephp/electron/resources/js/node_modules/electron-vite/dist/chunks/lib-3592fc5a.js:120:5)
    at createServer (/Users/irsyadadl/sites/desktop/vendor/nativephp/electron/resources/js/node_modules/electron-vite/dist/chunks/lib-86ea98bb.js:74:21)
    at async CAC.<anonymous> (/Users/irsyadadl/sites/desktop/vendor/nativephp/electron/resources/js/node_modules/electron-vite/dist/cli.js:48:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Is there anyone have the same things and has solved the problem?

@mraheelkhan
Copy link
Author

@irsyadadl , I remember someone posted a solution for this on other issues, maybe check this out #27
#27 (comment)

@irsyadadl
Copy link

@irsyadadl , I remember someone posted a solution for this on other issues, maybe check this out #27 #27 (comment)

Alright, but this is will only temporary, isn't it. I don't think modify the vendor is legal 👯

@mraheelkhan
Copy link
Author

@irsyadadl , Yes, that's correct, it's only a temporary fix so can give a shot to NativePhp. :-)

@irsyadadl
Copy link

Thank you @mraheelkhan

@joewardpr
Copy link

Same issue. This didn't work:

corepack prepare yarn@stable --activate

I guess I'll come back in a few weeks after a few revisions and updates to the documentation. I see that Jordan Dalton was able to get it installed, but then several of the core features wouldn't work for him. So, alpha is alpha. Exciting, but hard to differentiate between user error on my/our part and what just might be the initial pains of a brand new alpha release.

@mho22
Copy link

mho22 commented Jul 27, 2023

+1

@mpociot
Copy link
Member

mpociot commented Jul 29, 2023

Yarn is now no longer used and we default to npm everywhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests