18

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,
                },
            },
        }),
    ],
});
sos5020
  • 379
  • 1
  • 3
  • 10

16 Answers16

19

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.

miken32
  • 42,008
  • 16
  • 111
  • 154
Md Zahid
  • 440
  • 2
  • 8
9

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

Marinario Agalliu
  • 989
  • 10
  • 25
  • done this commands sudo npm cache clean -f sudo npm install -g n and after that done this command sudo n latest then fixed issue – Supun Madhushanka Aug 18 '22 at 16:39
  • Also works for Debian Bullseye (v11.6), where the stable version of the node package is only 12.22. You may need to delete/move an existing */usr/local/bin/node* and symlink /usr/local/n/versions/node/18.14.2/bin/node (or whichever version) to it. Once this is done, ``npm run build`` will work. – William Turrell Mar 02 '23 at 13:12
8

Type this it's works for me

npm run build
Dmitry Leiko
  • 3,970
  • 3
  • 25
  • 42
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 11 '22 at 03:48
  • This worked for me, but it is not included in the instructions at Tailwindcss. – JimB814 Jul 03 '23 at 14:46
3

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.

Alex01
  • 330
  • 3
  • 14
3

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
1

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

Then run npm run dev.

Alex01
  • 330
  • 3
  • 14
1

im learning laravel and wanted to put it live. And spent 5hrs tryin to look for answers lol. hope i can help you with this.

  • if your working in CPANEL
  • and you can only upload the file like mine since im using free tier
  • and having a folder structure like mine below
  • and all the public files are moved to public_html
  • and theres no more public folder in the "all"/project folder

folder structure

SOLN:

  • duplicate the build folder coming from vite
  • like the photo below or
  • or only put the manifest.json in the public/build/ in the "all"/proj folder
  • and only dont include the manifest.json in the public_html with the same folder structure.

solution duplicate build

  • laravel/framework ^10.10
  • vite ^4.0.0
  • tailwindcss
  • cpanel(can only upload zip in the file manager)
  • php 8.2
  • googiehost(free tier)
The OuterSpace
  • 151
  • 1
  • 4
0

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.

sos5020
  • 379
  • 1
  • 3
  • 10
0

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/
clem
  • 389
  • 1
  • 5
  • 9
0

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.
helvete
  • 2,455
  • 13
  • 33
  • 37
0

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.

ekene
  • 111
  • 8
0

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 above) or remove /public/build from the .gitignore file.

Tim Ramsey
  • 987
  • 13
  • 24
0

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.

XMehdi01
  • 5,538
  • 2
  • 10
  • 34
-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

  • There is no such hot file in the public folder. Can you please be more specific? – Leslie Joe Aug 02 '22 at 01:46
  • firstly you need to add this code in your vite.config.js import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; export default defineConfig({ buildDirectory: ['build',], plugins: [ laravel([ 'resources/css/app.css', 'resources/js/app.js', ]), ], server: { https: true, host: '0.0.0.0', }, }); ANd then move all the files in public/build to public_html except build/manifest.json and then it will work – Mohamed-Nour-Abshir Aug 03 '22 at 06:39
-1

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.

Harrison O
  • 1,119
  • 15
  • 20
-1

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
Hillcow
  • 890
  • 3
  • 19
  • 48