I have been having some issues with deployment. it is for the custom site https://rejaurrahman.co.uk/. Previously I had the project running using HTML, sass, and javascript. I upgraded it using next.js and sanity.io CMS. I checked when running yarn build I am getting no errors plus when I run the project locally I am getting no errors.
when I run the project locally I am getting no errors
Do you mean your Development command or your Build command?
You should always confirm it works locally by running exactly the same command locally as you’re running on Netlify, since most systems do different things under the two modes and you can accidentally confuse yourself.
When I run your repository locally with npm run build I receive the following error:
It looks like it’s case sensitivity related though, since it says it can’t resolve Headerlogo.module.scss while the file it’s within is HeaderLogo.component.tsx, notice the difference in capitalization for logo vs Logo.
@Ronny I can’t really help much with this one as I don’t really assist with Next.js based questions.
Projects built with it tend to have extra levels of complexity, automatically generated serverless functions, and use middleware, which all add up to extra potential points of failure.
That said, the root error is:
10:36:50 AM: SyntaxError: Unexpected token < in JSON at position 0
10:36:50 AM: at JSON.parse (<anonymous>)
It indicates something is running JSON.parse and that the json is malformed.
The < is usually an indication that it has accidentally been given a HTML string instead of JSON string.
When Next.js fails it tends to provide a URL you can check in their documentation for possible solutions, you can see that here in your log:
Normally I might say to check your redirects to make sure you don’t have a catch all rule that’s inadvertently returning HTML for a route that’s supposed to be JSON, but with Next.js from my perspective it could be literally anything causing it.