Laravel 5.4 can't run "php artisan preset react" comand

For Laravel 7+ projects:

composer require laravel/ui
php artisan ui react

https://laravel.com/docs/7.x/frontend#introduction

For Laravel 5.5+ projects:

php artisan preset react

https://medium.com/@taylorotwell/laravel-frontend-presets-eca312958def


Steps to run React in 7.x in laravel

composer require laravel/ui
php artisan ui react
npm install
npm dev

To check if for react working on laravel project you can add React Developer Chrome extension and hover on to the icon. It will show that application is using react. Then do

php artisan serve

and add below lines in your head of welcome.blade.php

<link href="/css/app.css" rel="stylesheet" />

Add Below line in your body tag

<div id="example"></div>

Add below line after closing body tag

<script src="/js/app.js"></script>

and remove the defined complete style Refresh your laravel page and hen you will hover on the extension for react which is added in chrome it will show that the page is using React JS. Successfully the ReactDOM is loaded. Hope this helps to run a basic laravel + react welcome page


In Laravel 7.x, the scaffolding API has changed:

php artisan ui react

https://laravel.com/docs/7.x/frontend