If your hosting does not have npm/node js installed, you can still deploy your Laravel application by following these steps:
Run the 'npm run prod' command on your local PC/project to build the assets for production.
Compress the Laravel project directory (including the node_modules folder) into a zip file.
Upload the zip file to your server and extract it in the desired directory. Make sure the index.php file points to the correct directory.
Configure the .env file to reflect the correct APP_URL.
Finally, create or modify the .htaccess file in the root directory with the following code:
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
This will redirect all requests to the public directory of your Laravel application.
If your hosting already has npm/node js installed, you can deploy your Laravel application by following these steps:
Upload your project to the server, preferably as a compressed zip file (make sure to exclude the /node_modules folder).
Open the terminal and navigate to the root directory of your project.
Run the 'npm run prod' command to build the assets for production.
Make sure the public/index.php file points to the correct directory.
Configure the .env file to reflect the correct APP_URL.
Finally, create or modify the .htaccess file in the root directory with the following code:
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
This will redirect all requests to the public directory of your Laravel application.
it always works for me, without change any source code