NextJS application build error with multiple [slug].js files

My NextJS application getting build error in netlify deployment, the issue only occurs when the application contains multiple [slug].js templates. The applications contain 4 slug templates in a different path of /pages folder like the blog, services, etc… When I removed all of the slug files and kept only one slug file the build ran successfully. Here below are the errors shown in the build logs.

Cannot read properties of undefined (reading 'map')
Unhandled error during request: TypeError: socialLinks.map is not a function
TypeError: Cannot read properties of undefined (reading 'filename')

But these are code-related errors and I managed it with better error handling. And I only got the errors while taking build by netlify and not in the local dev and build environment.

Also I didn’t make any code changes in the past months, I only update some contents in storyblok which connected with my nextjs app to manage the site contents, so when I change the content and I trigger the build with netlify build hook in storyblok so it will automatically build my app with the latest content. But in last week the builds were not running and I noticed the issue. A couple of months before some time I got the same error and It will solve when I tried with clear cache and deploy site option in netlify deploys. But this time it not working so I improved the error handling in my code and tried in the local dev and build environment it’s working perfectly. I noticed in netlify getting the errors only that contain multiple slug files so it’s something related to a concurrent build issue. Full build logs are added below.

Site ID: 1e56893a-d7d1-48aa-94f2-bcdbafff55e3
My site is an SSG and uses the next build && next export command for the build. also revalidate and fallback are false.

Due to privacy I cannot share the full logs here.

10:51:46 AM: Build ready to start
10:51:49 AM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)
10:51:49 AM: build-image tag: v4.10.1
10:51:49 AM: buildbot version: f7070267d9348624fde5c2d682aa32cc686742a6
10:51:50 AM: Fetching cached dependencies
10:51:50 AM: Starting to download cache of 595.6MB
10:51:56 AM: Finished downloading cache in 6.387842501s
10:51:56 AM: Starting to extract cache
10:51:59 AM: Finished extracting cache in 3.011828867s
10:51:59 AM: Finished fetching cache in 9.502588512s
10:51:59 AM: Starting to prepare the repo for build
10:52:00 AM: Preparing Git Reference refs/heads/main
10:52:00 AM: Parsing package.json dependencies
10:52:01 AM: Starting build script
10:52:01 AM: Installing dependencies
10:52:01 AM: Python version set to 2.7
10:52:01 AM: Started restoring cached node version
10:52:02 AM: Finished restoring cached node version
10:52:02 AM: v16.17.0 is already installed.
10:52:03 AM: Now using node v16.17.0 (npm v8.15.0)
10:52:03 AM: Started restoring cached build plugins
10:52:03 AM: Finished restoring cached build plugins
10:52:03 AM: Attempting ruby version 2.7.2, read from environment
10:52:03 AM: Using ruby version 2.7.2
10:52:03 AM: Using PHP version 8.0
10:52:03 AM: WARNING: The environment variable 'NODE_ENV' is set to 'production'. Any 'devDependencies' in package.json will not be installed
10:52:03 AM: Started restoring cached yarn cache
10:52:05 AM: Finished restoring cached yarn cache
10:52:05 AM: No yarn workspaces detected
10:52:05 AM: Started restoring cached node modules
10:52:05 AM: Finished restoring cached node modules
10:52:06 AM: Installing NPM modules using Yarn version 1.22.10
10:52:06 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
10:52:06 AM: npm WARN config location in the cache, and they are managed by
10:52:06 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
10:52:06 AM: yarn install v1.22.10
10:52:06 AM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
10:52:06 AM: [1/4] Resolving packages...
10:52:06 AM: success Already up-to-date.
10:52:06 AM: Done in 0.23s.
10:52:06 AM: NPM modules installed using Yarn
10:52:06 AM: Started restoring cached go cache
10:52:06 AM: Finished restoring cached go cache
10:52:06 AM: Installing Go version 1.16.5 (requested 1.16.5)
10:52:10 AM: unset GOOS;
10:52:10 AM: unset GOARCH;
10:52:10 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64';
10:52:10 AM: export PATH="/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64/bin:${PATH}";
10:52:10 AM: go version >&2;
10:52:10 AM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.16.5.linux.amd64.env"
10:52:10 AM: go version go1.16.5 linux/amd64
10:52:10 AM: Installing missing commands
10:52:10 AM: Verify run directory
10:52:11 AM: ​
10:52:11 AM: ────────────────────────────────────────────────────────────────
10:52:11 AM:   Netlify Build                                                 
10:52:11 AM: ────────────────────────────────────────────────────────────────
10:52:11 AM: ​
10:52:11 AM: ❯ Version
10:52:11 AM:   @netlify/build 27.15.7
10:52:11 AM: ​
10:52:11 AM: ❯ Flags
10:52:11 AM:   baseRelDir: true
10:52:11 AM:   buildId: 630706e9bf162700083abb85
10:52:11 AM:   deployId: 630706e9bf162700083abb87
10:52:11 AM: ​
10:52:11 AM: ❯ Current directory
10:52:11 AM:   /opt/build/repo
10:52:11 AM: ​
10:52:11 AM: ❯ Config file
10:52:11 AM:   /opt/build/repo/netlify.toml
10:52:11 AM: ​
10:52:11 AM: ❯ Context
10:52:11 AM:   production
10:52:12 AM: ​
10:52:12 AM: ────────────────────────────────────────────────────────────────
10:52:12 AM:   1. @netlify/plugin-nextjs (onPreBuild event)                  
10:52:12 AM: ────────────────────────────────────────────────────────────────
10:52:12 AM: ​
10:52:12 AM: Next.js cache restored.
10:52:12 AM: Not running Next Runtime
10:52:12 AM: ​
10:52:12 AM: (@netlify/plugin-nextjs onPreBuild completed in 93ms)
10:52:12 AM: ​
10:52:12 AM: ────────────────────────────────────────────────────────────────
10:52:12 AM:   2. build.command from netlify.toml                            
10:52:12 AM: ────────────────────────────────────────────────────────────────
10:52:12 AM: ​
10:52:12 AM: $ npm run deploy
10:52:13 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
10:52:13 AM: npm WARN config location in the cache, and they are managed by
10:52:13 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
10:52:13 AM: > abc-website@0.1.0 deploy
10:52:13 AM: > next build && next export
10:52:13 AM: warn  - The `target` config is deprecated and will be removed in a future version.
10:52:13 AM: See more info here https://nextjs.org/docs/messages/deprecated-target-config
10:52:13 AM: Browserslist: caniuse-lite is outdated. Please run:
10:52:13 AM: npx browserslist@latest --update-db
10:52:13 AM: Why you should do it regularly:
10:52:13 AM: https://github.com/browserslist/browserslist#browsers-data-updating
10:52:13 AM: info  - Checking validity of types...
10:52:13 AM: info  - Creating an optimized production build...
10:52:13 AM: Browserslist: caniuse-lite is outdated. Please run:
10:52:13 AM: npx browserslist@latest --update-db
10:52:13 AM: Why you should do it regularly:
10:52:13 AM: https://github.com/browserslist/browserslist#browsers-data-updating
10:52:14 AM: postcss-resolve-url: postcss.plugin was deprecated. Migration guide:
10:52:14 AM: https://evilmartians.com/chronicles/postcss-8-plugin-migration
10:52:14 AM: Browserslist: caniuse-lite is outdated. Please run:
10:52:14 AM:   npx browserslist@latest --update-db
10:52:14 AM:   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
10:52:22 AM: warn  - Compiled with warnings
10:52:22 AM: ./node_modules/follow-redirects/debug.js
10:52:22 AM: Module not found: Can't resolve 'debug' in '/opt/build/repo/node_modules/follow-redirects'
Did you mean './debug'?
10:52:22 AM: Requests that should resolve in the current directory need to start with './'.
10:52:22 AM: Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
10:52:22 AM: If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
10:52:22 AM: Import trace for requested module:
10:52:22 AM: ./node_modules/follow-redirects/index.js
10:52:22 AM: ./node_modules/axios/lib/adapters/http.js
10:52:22 AM: ./node_modules/axios/lib/defaults.js
10:52:22 AM: ./node_modules/axios/lib/axios.js
10:52:22 AM: ./node_modules/axios/index.js
10:52:22 AM: ./node_modules/storyblok-js-client/dist/index.cjs.js
10:52:22 AM: ./components/Blog/BlogBody.js
10:52:22 AM: ./pages/blog/[slug].js
10:52:22 AM: ./node_modules/next/dist/build/webpack/loaders/next-serverless-loader/index.js?page=%2Fblog%2F%5Bslug%5D&absolutePagePath=private-next-pages%2Fblog%2F%5Bslug%5D.js&absoluteAppPath=private-next-pages%2F_app.js&absoluteDocumentPath=next%2Fdist%2Fpages%2F_document&absoluteErrorPath=private-next-pages%2F_error.js&absolute404Path=private-next-pages%2F404.js&distDir=private-dot-next&buildId=NWg_jUw9Up7gKgbjf4b8I&assetPrefix=&generateEtags=true&poweredByHeader=true&canonicalBase=&basePath=&runtimeConfig=&previewProps=%7B%22previewModeId%22%3A%22939fcf5fcf5dbab389c43f3f7d4f6cf1%22%2C%22previewModeSigningKey%22%3A%220cae4d58bab0259384ad834dad303cf1fd797364e92c50e5a9f7892a279093f8%22%2C%22previewModeEncryptionKey%22%3A%22c886707eaa3fc213cde7f45136518cb4a1c153e279a7c03d2446b8e8e1cec5bb%22%7D&loadedEnvFiles=W10%3D&i18n=!
10:52:22 AM: info  - Collecting page data...
10:52:26 AM: info  - Generating static pages (0/301)
10:52:30 AM: The render method must receive an object with a content field, which is an array
10:52:30 AM: The render method must receive an object with a content field, which is an array
10:52:30 AM: The render method must receive an object with a content field, which is an array
10:52:30 AM: The render method must receive an object with a content field, which is an array
10:52:30 AM: The render method must receive an object with a content field, which is an array
10:52:31 AM: info  - Generating static pages (75/301)
10:52:32 AM: Unhandled error during request: TypeError: Cannot read properties of undefined (reading 'map')
10:52:32 AM:     at Footer (/opt/build/repo/.next/serverless/chunks/35.js:30:58)
10:52:32 AM:     at d (/opt/build/repo/.next/serverless/chunks/807.js:21925:498)
10:52:32 AM:     at bb (/opt/build/repo/.next/serverless/chunks/807.js:21928:16)
10:52:32 AM:     at a.b.render (/opt/build/repo/.next/serverless/chunks/807.js:21934:43)
10:52:32 AM:     at a.b.read (/opt/build/repo/.next/serverless/chunks/807.js:21933:83)
10:52:32 AM:     at Object.exports.renderToString (/opt/build/repo/.next/serverless/chunks/807.js:21944:138)
10:52:32 AM:     at Object.renderPage (/opt/build/repo/.next/serverless/chunks/807.js:17795:46)
10:52:32 AM:     at Object.defaultGetInitialProps (/opt/build/repo/.next/serverless/chunks/807.js:17448:51)
10:52:32 AM:     at Function.getInitialProps (/opt/build/repo/.next/serverless/chunks/807.js:11371:20)
10:52:32 AM:     at Object.loadGetInitialProps (/opt/build/repo/.next/serverless/chunks/807.js:14858:29)
10:52:32 AM: Error occurred prerendering page "/blog/web-application-development-trends". Read more: https://nextjs.org/docs/messages/prerender-error

Hey there!

Thanks for reaching out!

Looking at the error message you are receiving, it looks like your deploy is failing because the variables you are attempting to use as an array are coming up as undefined. Because of this, I think you should return to your code and check why that is happening. Without seeing a repository, I cannot make further suggestions about where that would be in your code exactly.

Based on your deploy log, I would start looking here: Netlify App

Let us know if this gets you on the right track!

Helllo Hillary,

Thanks for reaching out here, as I said in the question I’ve no issues when I deploy only 1 slug file instead of multiple files, A couple of months before some time I got the same error and It will solve when I tried with clear cache and deploy site option in netlify deploys. But this time it not working. I guess netlify has fail when pre-rendering multiple slug file exists.

Also I tried with console log my data in slug pages, and checked in netlify build logs there are some pages not getting the API data, those are undefined and empty array. but these issues are not in the local build.

It sounds like the code is somehow not able to handle errors well, or the order of execution of code is not well structured.

Are you able to share a minimal reproduction?

Hello @hrishikesh,

I don’t think it’s an error handling issue, I believe the code is well handled for errors since the build errors are not found in vercel platform and the local machine, there still building the app successfully. We only facing build errors in netlify.

And what do you expect to share a minimal reproduction? because we have some privacy issues for pushing out the code to the public.

It seems like your socialLinks is not an array hence no map function. Try to console log socialLinks to see what it is returning.

Also concerning the other pages you indicated you removed and then the application builds, try to add them again but this time around comment out your code and just return the page name for each of the pages.
It’s possible the cause of the error is from your code.
If the other pages are rendered by returning just the page name you rule out the cause of error is from Netlify’s end.
Hope this helps

Hello @clarnx ,

I getting not only this error and many others are in the build logs other than socialLinks.map. also this is happening from this month and I didn’t make any code changes in a couple of months. If it is a code error handling issue I believe it won’t work in Vercel and the local machine. Some other logs are added below


1:14:47 PM: TypeError: Cannot read properties of undefined (reading 'map')
1:14:47 PM:     at Footer (/opt/build/repo/.next/serverless/chunks/35.js:30:58)
1:14:47 PM:     at d (/opt/build/repo/.next/serverless/chunks/807.js:21925:498)
1:14:47 PM:     at bb (/opt/build/repo/.next/serverless/chunks/807.js:21928:16)
1:14:47 PM:     at a.b.render (/opt/build/repo/.next/serverless/chunks/807.js:21934:43)
1:14:47 PM:     at a.b.read (/opt/build/repo/.next/serverless/chunks/807.js:21933:83)
1:14:47 PM:     at Object.exports.renderToString (/opt/build/repo/.next/serverless/chunks/807.js:21944:138)
1:14:47 PM:     at Object.renderPage (/opt/build/repo/.next/serverless/chunks/807.js:17795:46)
1:14:47 PM:     at Object.defaultGetInitialProps (/opt/build/repo/.next/serverless/chunks/807.js:17448:51)
1:14:47 PM:     at Function.getInitialProps (/opt/build/repo/.next/serverless/chunks/807.js:11371:20)
1:14:47 PM:     at Object.loadGetInitialProps (/opt/build/repo/.next/serverless/chunks/807.js:14858:29)
1:14:47 PM: Unhandled error during request: TypeError: Cannot read properties of undefined (reading 'filename')
1:14:47 PM:     at Navigation (/opt/build/repo/.next/serverless/chunks/35.js:249:69)
1:14:47 PM:     at d (/opt/build/repo/.next/serverless/chunks/807.js:21925:498)
1:14:47 PM:     at bb (/opt/build/repo/.next/serverless/chunks/807.js:21928:16)
1:14:47 PM:     at a.b.render (/opt/build/repo/.next/serverless/chunks/807.js:21934:43)
1:14:47 PM:     at a.b.read (/opt/build/repo/.next/serverless/chunks/807.js:21933:83)
1:14:47 PM:     at Object.exports.renderToString (/opt/build/repo/.next/serverless/chunks/807.js:21944:138)
1:14:47 PM:     at Object.renderPage (/opt/build/repo/.next/serverless/chunks/807.js:17795:46)
1:14:47 PM:     at Object.defaultGetInitialProps (/opt/build/repo/.next/serverless/chunks/807.js:17448:51)
1:14:47 PM:     at Function.getInitialProps (/opt/build/repo/.next/serverless/chunks/807.js:11371:20)
1:14:47 PM:     at Object.loadGetInitialProps (/opt/build/repo/.next/serverless/chunks/807.js:14858:29)
1:14:47 PM: Error occurred prerendering page "/blog/healthcare-powered-by-cloud-native". Read more: https://nextjs.org/docs/messages/prerender-error
1:14:47 PM: TypeError: Cannot read properties of undefined (reading 'filename')
1:14:47 PM:     at Navigation (/opt/build/repo/.next/serverless/chunks/35.js:249:69)
1:14:47 PM:     at d (/opt/build/repo/.next/serverless/chunks/807.js:21925:498)
1:14:47 PM:     at bb (/opt/build/repo/.next/serverless/chunks/807.js:21928:16)
1:14:47 PM:     at a.b.render (/opt/build/repo/.next/serverless/chunks/807.js:21934:43)
1:14:47 PM:     at a.b.read (/opt/build/repo/.next/serverless/chunks/807.js:21933:83)
1:14:47 PM:     at Object.exports.renderToString (/opt/build/repo/.next/serverless/chunks/807.js:21944:138)
1:14:47 PM:     at Object.renderPage (/opt/build/repo/.next/serverless/chunks/807.js:17795:46)
1:14:47 PM:     at Object.defaultGetInitialProps (/opt/build/repo/.next/serverless/chunks/807.js:17448:51)
1:14:47 PM:     at Function.getInitialProps (/opt/build/repo/.next/serverless/chunks/807.js:11371:20)
1:14:47 PM:     at Object.loadGetInitialProps (/opt/build/repo/.next/serverless/chunks/807.js:14858:29)
1:14:47 PM: Unhandled error during request: TypeError: Cannot read properties of undefined (reading 'filename')
1:14:47 PM:     at Navigation (/opt/build/repo/.next/serverless/chunks/35.js:249:69)
1:14:47 PM:     at d (/opt/build/repo/.next/serverless/chunks/807.js:21925:498)
1:14:47 PM:     at bb (/opt/build/repo/.next/serverless/chunks/807.js:21928:16)
1:14:47 PM:     at a.b.render (/opt/build/repo/.next/serverless/chunks/807.js:21934:43)
1:14:47 PM:     at a.b.read (/opt/build/repo/.next/serverless/chunks/807.js:21933:83)
1:14:47 PM:     at Object.exports.renderToString (/opt/build/repo/.next/serverless/chunks/807.js:21944:138)
1:14:47 PM:     at Object.renderPage (/opt/build/repo/.next/serverless/chunks/807.js:17795:46)
1:14:47 PM:     at Object.defaultGetInitialProps (/opt/build/repo/.next/serverless/chunks/807.js:17448:51)
1:14:47 PM:     at Function.getInitialProps (/opt/build/repo/.next/serverless/chunks/807.js:11371:20)
1:14:47 PM:     at Object.loadGetInitialProps (/opt/build/repo/.next/serverless/chunks/807.js:14858:29)
1:14:47 PM: Error occurred prerendering page "/blog/mobile-app-development-experts-ultimate-guide". Read more: https://nextjs.org/docs/messages/prerender-error

@nikhil I understand your code works on Vercel and the local machine. However they are different environments. In order to rule out the issue we need to detect the cause of the problem. Sometimes what we think is the problem might not be the case.

One error can cause other errors. Based on the log you posted it seems the TypeError is still common.
Since you stated you cannot share code based on privacy issues the only way I can help is trying to rule out possible errors. Sometimes the cause could be something you least expected. That is why I’m asking you to console log the socialLinks.
Let’s start from there. The output of the socialLinks can help us. Once we know its undefined then we know that your the way you are fetching the socialLinks is not working on Netlify.

I know it can be frustrating to debug but sometimes it’s the least expected that could be the cause of the problem.
Kindly let me know if the console log output of your socialLinks is undefined or contains an array of links.

Hello @clarnx,

Thanks for the response, the socialLinks is a common component that is placed in our application Footer, so the Footer is the same for all pages and when I deleted all slug files or keeping only one slug file instead then the build working fine with all other landing pages, so my question is should I track on the socialLinks response? or is that like a concurrent build issue from netlify?

@nikhil thanks for adding more information.
Okay so first of all I want to find out if you are fetching the social links from an API or its an array in the socialLinks components you stated?

Sorry @clarnx there is a mistake in what I said last comment, socialLinks is not belong the common Footer component, it’s an individual page data for Schema markups.

And the social links data fetching from storyblok API, the site content is managed from there. I added some source code below from one of the slug file.

In addition, when I put console log the socialLinks data and tried for new build the new log getting with fulfilled data, also this time socialLinks map error not in the first line up, now I getting first error is other map related issues which are same I mentioned in my previous comment, if you are able to access my site build log please visit it.

import Layout from "../../components/Layout";
import { getHeader, getFooter, getAllServiceWithSlug, getService, getServicePagecount, getBlogList, getTestimonialForService } from "../../lib/api"; 
import ServiceDetails from "../../components/Services/Details";
import { JsonLd } from "react-schemaorg";
import { TestimonialContent, aggregateRating, offers, OrgName, schemaCompanyLogo, SchemaProductMpn, SchemaProductSKU, SiteBaseURL, socialMediaLinks } from "../../utils";


export async function getStaticProps({ params, preview = null }) {
    const serviceData = await getService(params.slug, preview) || null; 
    const serviceTestimonialsData = await getTestimonialForService(params.slug, preview) || [];
    
    let notfound = false;
    if (!serviceData.service) {
        notfound = true;
    }
    const header = (await getHeader(preview)) || []
    const footer = (await getFooter(preview)) || []
    const blogListData = await getBlogList() || [];
     

    return {
        props: { header, footer, serviceData, blogListData, serviceTestimonialsData },
        revalidate: process.env.REACT_APP_STORYBLOK_REVALIDATE === "false" ? false : 1,
        notFound: notfound
    }
}

export async function getStaticPaths() { 
    const allServices = await getPaginateddata();
    return {
        paths: allServices && allServices.length > 0 && allServices.map((blog) => `/${blog.full_slug}`) || [],
        fallback: process.env.REACT_APP_STORYBLOK_REVALIDATE === "false" ? false : 'blocking',
    }
}


async function getPaginateddata() {
    const output = [];
    const pagesize = 100;
    const allPosts = await getServicePagecount();
    const totalpages = Math.ceil(allPosts.total / pagesize);
    for (let i = 1; i <= totalpages; i++) {
      const data = await getAllServiceWithSlug(i, pagesize);
      output.push(...data);
    }
    return output;
}

export default function Blog({ header, serviceData, footer, blogListData, serviceTestimonialsData }) { 

    const headerContent = header && header.length > 0 && header[0].content;
    const footerContent = footer && footer.length > 0 && footer[0].content;  
    const serviceContent = serviceData?.service?.content;
    const serviceDataList = serviceContent;

    const serviceTestimonials =  TestimonialContent(serviceTestimonialsData&&serviceTestimonialsData[0]);

    const servicePageTitle = serviceContent?.body[0].title;
    const serviceSubPageSlug = serviceData?.service?.full_slug;
    const serviceDescription = serviceContent?.body[0].description;
    const casestudiesData = []; 
    const socialLinks = socialMediaLinks(footerContent && footerContent.social_links)
    const schemaLogoFile = schemaCompanyLogo(headerContent);

    console.log("footerContent===>", footerContent);
    console.log("socialLinks===>", socialLinks);

    const testimonialSchema = serviceTestimonials && serviceTestimonials.length > 0 && serviceTestimonials.map((item) => {
      const name = item.author_name;
      const reviewBody = item.testimonial;
      const testimonialsDate = item.published_at;
      return (
        {
            "@type": "Review",
            name,
            reviewBody,
            "reviewRating": {
                "@type": "Rating",
                "ratingValue": "5"
            },
            "datePublished": testimonialsDate,
            "author": 
            {
                "@type": "Person", 
                name
            }
        }
      )
    }); 
   
    return (
      <Layout
        headerContent={headerContent}
        footerContent={footerContent}
        metaValues={serviceDataList.seo}
      >

        {/* Schema for Organization */}
        <JsonLd
          item={{
            "@context": "https://schema.org",
            "@type": "Organization",
            name: OrgName,
            url: SiteBaseURL + serviceSubPageSlug,
            logo: schemaLogoFile,
            sameAs: socialLinks,
          }}
        />

        {/* Schema for Product */}
        <JsonLd
          item={{
            "@context": "https://schema.org",
            "@type": "Product",
            name: OrgName,
            image: schemaLogoFile,
            description: serviceDescription ? serviceDescription : " ",
            mpn: SchemaProductMpn,
            sku: SchemaProductSKU,
            offers: { ...offers },
            brand: {
              "@type": "Brand",
              name: OrgName,
            },
            aggregateRating: { ...aggregateRating },
            review: [testimonialSchema ? testimonialSchema : " "],
          }}
        />

        {/* Schema for BreadcrumbList - Home,Parent and current page */}
        <JsonLd
          item={{
            "@context": "https://schema.org/",
            "@type": "BreadcrumbList",
            itemListElement: [
              {
                "@type": "ListItem",
                position: 1,
                name: OrgName + " Homepage",
                item: SiteBaseURL,
              },
              {
                "@type": "ListItem",
                position: 2,
                name: "Services",
                item: SiteBaseURL + "services",
              },
              {
                "@type": "ListItem",
                position: 3,
                name: servicePageTitle,
                item: SiteBaseURL + serviceSubPageSlug,
              },
            ],
          }}
        />

        <ServiceDetails
          content={serviceDataList}
          blogListData={blogListData}
          testimonialsData={serviceTestimonials}
          casestudiesData={casestudiesData}
        />

      </Layout>
    );
}

@nikhil thanks for adding more clarity and sharing more information. Before I continue note that I cannot access your site build log as its only private to you. You don’t have to share confidential information.

At this point it will be best to console log all the variables in the component to see which one is the root cause. I’m guessing one of the variables is returning undefined.

Console log all the variables and give feedback if all the data is returning or one of them is undefined.

Thanks

1 Like

Hey @nikhil,

I see you mentioned it works locally with the dev command, but would you be able to try using your build command which is next build && next export to see if the build works?

If it does, would you be able to create a minimal repo and share it with us?

We also checked this further and it appears that you might be using target: serverless in your Next.js config. Could you try removing that?

Yes I tried with next build && next export command for the local build and it works fine there, also tried with remove by target: serverless but the errors remain the same.

Hey @nikhil,

Thanks for trying that. Unfortunately, to make any further guesses about the problem, we would need to see either the repo or a minimal reproduction of the issue - so you can take out all the private stuff from your repo as long as the stuff you keep in, still shows the issue to us and the devs.

1 Like