oliverbusk's avatar

Vite manifest not found - deployment on Forge

I am trying to deploy a brand new Laravel 9 site with Vite.

I have the site running locally just fine, and the deployment is running via Laravel forge using the default deployment script:

cd /home/forge/default
git pull origin $FORGE_SITE_BRANCH

$FORGE_COMPOSER install --no-interaction --prefer-dist --optimize-autoloader

( flock -w 10 9 || exit 1
    echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock

if [ -f artisan ]; then
    $FORGE_PHP artisan migrate --force
fi

Before pushing my changes from my local to remote server, I run:

npm run build

However, when the site has been deployed to forge, I get the below error:

(Exception(code: 0): Vite manifest not found at: /home/forge/default/public/build/manifest.json at /home/forge/default/vendor/laravel/framework/src/Illuminate/Foundation/Vite.php:139)

When I ssh into my server, this is the content of the /public folder:

.
└── public/
    ├── favicon.ico
    ├── index.php
    └── robots.txt

Shouldn't the /build folder be available on the production site as well, or am I missing something? Please note in my standard generated .gitignore file, these paths are excluded:

/public/build
/public/hot
/public/storage
0 likes
16 replies
SteamDiesel's avatar

@Cruorzy yeah that was it for me, too. I just removed Build from my .gitignore

/node_modules
!/public/build
/public/hot
/public/storage
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.idea
/.vscode
5 likes
georgiarnaudov's avatar

@miguelst Because you only need them to build the assets. After that, they are just using unnecessary space on the machine.

1 like
waywardson's avatar

@Cruorzy this one has saved me twice now moving stuff to Forge. StackOverflow just says to run npm install which does not fix it - but this fixes it:

Error message:

production.ERROR: Vite manifest not found at: /home/forge
1 like
Cruorzy's avatar

@22289d Glad i could help.

Found out this is better

npm ci
npm run build
rm -rf node_modules

(Copied from Stack overflow)

  • The project must have an existing package-lock.json or npm-shrinkwrap.json.
  • If dependencies in the package lock do not match those in package.json, npm ci will exit with an error, instead of updating the package lock.
  • npm ci can only install entire projects at a time: individual dependencies cannot be added with this command.
  • If a node_modules is already present, it will be automatically removed before npm ci begins its install.
  • It will never write to package.json or any of the package-locks: installs are essentially frozen.

Full explanation can be found here: https://stackoverflow.com/a/53325242

3 likes
SteamDiesel's avatar

@NoLAstNamE oh, thanks for asking! I didn;t mean to ignore, I haven't been on LC for a few months. I ended up getting on a project that was a nightmare, then I left that to join a business with a laravel app I maintain. I've abandoned that streaming project entirely, but I think I'll stream my hobby project and another project, too. I'll probably get on twitch tomorrow, actually!

1 like
malanciault's avatar

Did the trick for me, but only after I restarted the Forge server. Thanks !

stuartcusack's avatar

Total pain this one. I don't understand it. Anyway, this is how I adjust my .gitignore file.

/public/build/*
!/public/build/
!/public/build/manifest.json

This may be related to Filament. It seems to happen only on my Filament projects.

PROBLEM SOLVED!! My problem was down to using the Vite facade in my FilamentServiceProvider:

I had this:

->favicon(Vite::asset('resources/images/favicons/favicon-32x32.png'))

Updating it to this solved the problem:

->favicon(asset('images/favicon-32x32.png'))
nikoi's avatar

Hey there, I know this is an old post. But every solution mentioned here is not really a good solution, because you are pushing the assets to the git repo.

Just add 2 lines to your Laravel Forge deployment script: npm install npm run build

Now this would happen automatically on deployment, so you don't need to care about running a build. This is part of deployment.

You can develop with "npm run dev" and as soon as you are ready, push it to the repo and deploy on laravel forge (maybe you have automatically deployments from the repository, then you don't have to do even the deployment manually).

1 like
stuartcusack's avatar

What you say is true but my problem was because of something different. See above. Thanks!

Please or to participate in this conversation.