earmsby's avatar

Forge was unable to build the frontend assets for your site

I am trying to set up a new site on a Forge server but I keep running into the message in the subject.

I've created a number of sites from Github repos on Forge but not run into this error. Not sure where to look to resolve the problem. Suggestions?

0 likes
4 replies
LaryAI's avatar
Level 58

Certainly! This error from Laravel Forge usually means that Forge couldn't complete the build process for your frontend assets (for example, running npm install && npm run build or similar commands defined in your deployment script). Here are steps to troubleshoot and resolve this issue:


1. Check Your Deploy Script

Forge runs the deploy script you configure under "Site > Deploy Script". Make sure it contains the proper frontend build steps:

cd /home/forge/{{ domain }}
git pull origin main
composer install --no-interaction --prefer-dist --optimize-autoloader
npm ci
npm run build
php artisan migrate --force

Adjust as needed for your setup (e.g., branch name, Yarn/Vite/etc.).


2. Review the Deployment Output

When a deployment fails, Forge offers the full output in the "Deployment" tab for your site. Scroll through the output to locate the step that failed; common problems include:

  • Missing Node or npm
  • Build script errors
  • Out of memory issues

3. Ensure Node.js & npm Are Installed

SSH into your Forge server and run:

node -v
npm -v

If you get "command not found" or a very old version, you can install/upgrade Node.js:

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs

(Replace 18.x with your desired version.)


4. Fix Permissions

Sometimes, permission issues cause builds to fail. Run:

sudo chown -R forge:forge /home/forge/{{ domain }}

5. Check Dependency Issues

Sometimes, packages need build tools (e.g., Python, build-essential, etc). Install them:

sudo apt-get update
sudo apt-get install -y build-essential python3

6. Manual Build Test

SSH into the server, navigate to your site, and try building manually:

cd /home/forge/{{ domain }}
npm ci
npm run build

Look for errors and resolve them as you would locally.


7. Deployment Hooks

Consider running frontend builds locally, committing the built files, and skipping frontend builds on the server for simplicity.


Summary

  • Double-check the deploy script
  • Ensure Node.js/npm is installed and current
  • SSH in and try the build steps manually
  • Review and fix any errors shown

If you paste the exact build error message here, I can help more specifically!

earmsby's avatar

I'm not sure how I can check the deployment script before I create a new site. Isn't the script set up after you create the site?

Also, I cannot do step 2 "2. Review the Deployment Output." In the deployments tab it just says no deployments yet. So, I feel like I'm kind of stuck.

Perhaps I'll try creating a whole new app/repo and copying over most of my work to a new version.

earmsby's avatar

I'm still stuck on this.

  1. I changed the deployment script to what is shown by Larry AI (changing the domain, of course).
  2. When I ran the deployment again, the error is:
fatal: not a git repository (or any of the parent directories): .git
=> Deployment failed: An unexpected error occurred during deployment.
  1. I SSHed into the version checked the versions of node and npm: node=v.22.13.0 & npm=10.9.2

Not sure if I should try step #4. My app has nothing to do with Python, so I imagine step 5 is not applicable. Also not sure if I should try #6 and I don't understand #7 at all.

I've deleted the site and retried it several times and it always fails in the same way. I really don't understand why the deploy script says "not a git repository."

At this point, I'm wondering if the problem is with the Git repo itself...

earmsby's avatar

FWIW, while I don't know the exact cause of this, I decided there was probably something off-kilter with my project in general and therefore in the git repo. So, I started over from scratch and created a brand new project which I successfully deployed to the Forge server. Now, I'm just building back the data and functions in my app but so far, deployment has been working fine.

Please or to participate in this conversation.