sos5020
sos5020

Reputation: 719

Vite manifest not found

I Working on project that working with laravel 9 and Vite with laravel-vite,

In Dev environment all thing working fine, but in production cPanel server I has this issue

Vite manifest not found at: /home/???????/cart_shop/public/build/manifest.json

# With 

Missing Vite Manifest File
Did you forget to run `npm install && npm run dev`?

I tried to solve the problem but nothing work, I need to change the public folder and the sup folder build file place from vite.config.js but I don't find the way to do that.

Note that: the file sequence is changed in cPanel shared server from

- home
    - public_html
        - cart_shop
           - Root
           - public
           - etc

To

- home
    - public_html
       - public files and folders  // I changed the index URLs too.
- cart_shop
    - Root
    - etc

my vite.config.js config is like:

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
    plugins: [
        laravel({
            input: 'resources/js/app.js',
        }),
        vue({
            template: {
                transformAssetUrls: {
                    base: null,
                    includeAbsolute: false,
                },
            },
        }),
    ],
});

Upvotes: 51

Views: 160976

Answers (21)

Othman
Othman

Reputation: 59

I just encountered same error on Cpanel Shared hosting. The only way i resolve it is

  1. run on cmd of the project location npm install and npm run build on local computer
  2. Copy/Upload the build folder
  3. Patse or ensure it is in the location that the error shows it is not found in

Upvotes: 1

Amr Omar
Amr Omar

Reputation: 557

Using Vite version 5 and Laravel version 10

I had this issue: Vite manifest not found at: /releases/20240417/public/manifest.json

the solution works for me to add this line in the AppServiceProvider.php

\Illuminate\Support\Facades\Vite::useBuildDirectory('.');

Upvotes: 3

ganji
ganji

Reputation: 844

In my case no solutions worked and finally I find this way to: delete node_modules directory and then

run

npm install

and make sure you have a permission to run this command. After that run

npm run build
npm run dev

Upvotes: 1

Logbahadur Gurkha
Logbahadur Gurkha

Reputation: 1601

You just need to bind the public path with the app. You can do this in the pubic/index.php file and bootstrap/app.php file.

I always prefer to update in the public/index.php file. Refer to the below code.

<?php

use Illuminate\Http\Request;

define('LARAVEL_START', microtime(true));

// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/../laravel-core/storage/framework/maintenance.php')) {
    require $maintenance;
}

// Register the Composer autoloader...
require __DIR__.'/../laravel-core/vendor/autoload.php';


// Bootstrap Laravel and handle the request...
$app = require_once __DIR__.'/../laravel-core/bootstrap/app.php';

app()->usePublicPath(__DIR__); // app bind here

$app->handleRequest(Request::capture());

Upvotes: 2

Eaweb
Eaweb

Reputation: 988

I faced an issue that displayed a similar "Vite manifest not found at:..." error message today.

In my case, this happend when I cloned my own Laravel project that I had hosted on Github on a new computer. Seems like the issue in my case was because I used Laravel Breeze and the package had some Vite dependencies.

The fix that worked for me was to run the following commands before running php artisan serve

  1. npm install
  2. npm run build

Again, its important to run the above commands in the same order and restart your Laravel server after running the commands.

Upvotes: 0

Tim Ramsey
Tim Ramsey

Reputation: 1135

This is because Laravel has /public/build added to the .gitignore file. You can either npm install && npm run build to install these files(as suggested by other answers) or remove /public/build from the .gitignore file.

Upvotes: 7

The OuterSpace
The OuterSpace

Reputation: 229

I'm wanted to deploy it to a PROD environment too. I spent around 5 hours searching for answers, hoping that I can share my findings with you.

  • if you're working with cPanel
  • your folder structure resembles mine
  • all public files are moved to public_html
  • where is no more public folder in the application (all) folder

folder structure

Solution:

  • Duplicate the 'build' folder generated by Vite, as shown in the image below. or
  • Alternatively, place only the manifest.json file in the public/build directory within the 'all' or project folder.
  • Do not include the manifest.json file in the public_html directory with the same folder structure.

solution duplicate build

  • laravel/framework ^10.10
  • vite ^4.0.0
  • tailwindcss
  • cPanel
  • php 8.2
  • googiehost

Upvotes: 6

XMehdi01
XMehdi01

Reputation: 1

Hy , sorry for the late comment :

if you facing this issue , you can run these command on terminal

First Command:

-> npm install --save-dev vite laravel-vite-plugin

Second Command:

-> npm run build

Your problem is solved.

Upvotes: 1

ekene
ekene

Reputation: 301

Check that your vite build was successful. I recently deployed a laravel + vite app on render and I was sure that the npm run dev step was taken. I was getting the 'manifest not found' error until I checked the logs carefully and found the build wasn't succeeding because of missing import.

Upvotes: 0

Sayed Newaz
Sayed Newaz

Reputation: 113

Run these commands on terminal

npm install --save-dev vite laravel-vite-plugin

Then you need to update your package.json file

"scripts": { "dev": "vite", "build": "vite build" }

Finally, you can trigger this command below to build Vite and create the manifest file.

npm run build

Upvotes: 6

Md Zahid
Md Zahid

Reputation: 1152

In my case, I have solved this problem by doing some things.

First of all, I have made sure required npm packages are installed by running this command

npm install

After that, I have run

npm run build 

To build assets and create the manifest file.

Upvotes: 69

Hillcow
Hillcow

Reputation: 969

What fixed it for me was to use a recent version of Node.

You can use nvm for that:

nvm use 19
npm run dev

Upvotes: -1

Mohammad Abdorrahmani
Mohammad Abdorrahmani

Reputation: 104

I solved this problem like this:

  1. npm run build
  2. When you put public files inside public_html. Create a public file in the root of the domain and put the build folder inside it And it was done.

Upvotes: 0

Alex01
Alex01

Reputation: 358

Remove @vite(['resources/sass/app.scss', 'resources/js/app.js']) from the <head> of the file app.blade.php on Laravel 9. And now it works like a charm.

Upvotes: 5

Alex01
Alex01

Reputation: 358

Update Node.js to its latest version: https://nodejs.org/en/

Then run npm run dev.

Upvotes: 1

Tharaka Gamage
Tharaka Gamage

Reputation: 189

Type this it's works for me

npm run build

Upvotes: 17

Harrison O
Harrison O

Reputation: 1210

I had a similar problem and I was able to resolve it by installing the node current stable version. In my case, the node version was 14+, and when I upgraded to the current version which is v16.17.0, everything works just fine. The comments here were helpful.

Visit the official node website to download and install the latest node version.

Upvotes: -1

clem
clem

Reputation: 424

If the manifest.json file does exist but you're still seeing this error, make sure the permissions are good:

sudo chown www-data:www-data -R public/build/
sudo chmod g+w -R public/build/

Upvotes: 0

Marinario Agalliu
Marinario Agalliu

Reputation: 1179

I had the same issue only because of node version. I upgraded to the latest version and it's working properly.

For Ubuntu use n module from npm in order to upgrade node:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

To upgrade to latest version (and not current stable) version, you can use:

sudo n latest

You may need also to Fix PATH:

  sudo apt-get install --reinstall nodejs-legacy     # fix /usr/bin/node

To undo:

  sudo n rm 6.0.0     # replace number with version of Node that was installed
  sudo npm uninstall -g n

You may need to restart your terminal to see the updated node version.

Found in Ask Ubuntu

Upvotes: 14

Mohamed-Nour-Abshir
Mohamed-Nour-Abshir

Reputation: 1

just go to your public folder and there is a hot file in that file there is a link like this http://127.0.0.1:3000 change this link to your domain link i mean your website link

Upvotes: -1

sos5020
sos5020

Reputation: 719

The issue solved,

first: I try adding publicDirectory configration into laravel-vite-plugin setting in vite.config.js that solve the build issue but manifest still not founded.

Finally: I move all files and folders except build from public to bublic_html then npm run build and it's working fine.

Upvotes: 0

Related Questions