Hello all, I have a deployment failure. My root structure is as so:
The netlify.toml on the root contains:
base = “frontend”
The netlify.toml inside frontend, which I’m trying to deploy, contains:
publish = “build”
command = “yarn build”
The following redirect is intended for use with most SPAs that handle routing internally.
from = “/*”
to = “/index.html”
status = 200
The package.json file, located within the frontend folder, contains:
Locally, I use yarn to create my dev using yarn dev and yarn build. Both work fine locally with no errors. I have created two netlify.toml files because another thread mentioned this was a possible solution. This is a nextjs project using the Ghost Content API, if that has any relevance.
When I try to build, the yarn build command runs repeatedly before resulting in a ton of errors and fails. The link to the log is here: Netlify App
I would copy+paste the log but I reach the max character limit when trying to do so. If you need the full log, I can email or post it somewhere else.
You can attach the log as a screenshot, or paste the part you think is most relevant, generally from the building site part.
Sure, here is what is happening:
Oh no, you cropped the main text in the first image you sent. It just shows the time. If your deploy log is public, you could also link to the log.
Didn’t know I can do that, I’ve also updated the original thread, thanks! Here it is: Netlify App
Oh turns out, you didn’t crop, that’s how it is. This is strange, I’ll take a look into it.
Oh seems like your problem is your
package.json. In that, your script has the following:
"dev": "next dev",
"build": "yarn build",
"start": "next start"
See your build command… it’s just
yarn build. So, what’s happening is your build is stuck in a loop. yarn build is calling for yarn build which is again calling yarn build. Replace that part with your actual build command and it should work.
Now I get this message when I switch yarn build to next build: Netlify App
That means your publish directory is wrong. Try building locally once to see where you’re getting the buid files. Then use that folder as publish path.
Thank you, that got rid of the errors, but when I try to access the domain (https://from-the-ground-up.netlify.app/), it still says page not found.
I see that the log says it is running on localhost:3000 (Netlify App):
I am following the tutorial for deploying nextjs projects here and it doesn’t mention doing that: How to Deploy Next.js Sites to Netlify — 5-Minute Tutorial
Would I need to update the localhost info to simply localhost instead of localhost:3000?
You’re running a development server, which is not supported on Netlify. You need to generate static HTML, CSS, JS files. I guess, in NextJS, the command is
next build && next export. The tutorial that you mentioned might be outdated, thus the confusion.
Thank you so much for the help. I’ve added
next export to my package.json and that seems to have solved the issue. I also noticed that the plugins recommended on the previous article I mentioned also causes a conflict with nextjs projects. So yes, that article seems to be outdated.
Hello @gibumkang ,
Would you be able to post your full package.json? Additionally, can you elaborate on what is outdated in the article above? I want to make sure I can look into that on your behalf.