Build Fails Next JS 13 (Not using experimental app directory)

The site builds locally but having issues with build on Netlify. Not sure what to make of terminal response. Perhaps a plugin config issues?

site name: mardirosianlaw.netlify.app

12:32:34 PM: build-image version: 1ca34a93198b041e44214013884c57d146a23fed (focal)
12:32:34 PM: build-image tag: v4.16.4
12:32:34 PM: buildbot version: 5d70ebdb976733297fb4c90b41002389a248e2df
12:32:35 PM: Building without cache
12:32:35 PM: Starting to prepare the repo for build
12:32:35 PM: No cached dependencies found. Cloning fresh repo
12:32:35 PM: git clone --filter=blob:none https://github.com/mardirosianlaw/mardio-law-static
12:32:35 PM: Preparing Git Reference refs/heads/main
12:32:36 PM: Parsing package.json dependencies
12:32:38 PM: Starting build script
12:32:38 PM: Installing dependencies
12:32:38 PM: Python version set to 2.7
12:32:38 PM: v16.19.0 is already installed.
12:32:39 PM: Now using node v16.19.0 (npm v8.19.3)
12:32:39 PM: Enabling Node.js Corepack
12:32:39 PM: Started restoring cached build plugins
12:32:39 PM: Finished restoring cached build plugins
12:32:39 PM: Attempting Ruby version 2.7.2, read from environment
12:32:40 PM: Using Ruby version 2.7.2
12:32:40 PM: Using PHP version 8.0
12:32:40 PM: Started restoring cached corepack dependencies
12:32:40 PM: mv: cannot move ‘/opt/build/cache/.node/corepack’ to ‘/opt/buildhome/.node/corepack’: No such file or directory
12:32:40 PM: Finished restoring cached corepack dependencies
12:32:40 PM: No npm workspaces detected
12:32:40 PM: Started restoring cached node modules
12:32:40 PM: Finished restoring cached node modules
12:32:40 PM: Bypassing sha validation. Running pre & post install scripts
12:32:40 PM: Installing npm packages using npm version 8.19.3
12:32:46 PM: added 298 packages, and audited 299 packages in 6s
12:32:46 PM: 111 packages are looking for funding
12:32:46 PM: run npm fund for details
12:32:46 PM: found 0 vulnerabilities
12:32:46 PM: npm packages installed
12:32:46 PM: Started restoring cached go cache
12:32:46 PM: Finished restoring cached go cache
12:32:46 PM: go version go1.19.5 linux/amd64
12:32:47 PM: Detected 1 framework(s)
12:32:47 PM: “next” at version “13.0.6”
12:32:47 PM: Installing missing commands
12:32:47 PM: Verify run directory
12:32:47 PM: Section completed: initializing
12:32:48 PM: ​
12:32:48 PM: Netlify Build
12:32:48 PM: ────────────────────────────────────────────────────────────────
12:32:48 PM: ​
12:32:48 PM: ❯ Version
12:32:48 PM: @netlify/build 29.5.1
12:32:48 PM: ​
12:32:48 PM: ❯ Flags
12:32:48 PM: baseRelDir: true
12:32:48 PM: buildId: 63d418c008f0032b6c84e5ea
12:32:48 PM: deployId: 63d418c008f0032b6c84e5ec
12:32:48 PM: ​
12:32:48 PM: ❯ Current directory
12:32:48 PM: /opt/build/repo
12:32:48 PM: ​
12:32:48 PM: ❯ Config file
12:32:48 PM: No config file was defined: using default values.
12:32:48 PM: ​
12:32:48 PM: ❯ Context
12:32:48 PM: production
12:32:48 PM: ​
12:32:48 PM: ❯ Installing plugins
12:32:48 PM: - @netlify/plugin-nextjs@4.30.1
12:32:56 PM: ​
12:32:56 PM: ❯ Using Next.js Runtime - v4.30.1
12:32:57 PM: ​
12:32:57 PM: 1. @netlify/plugin-nextjs (onPreBuild event)
12:32:57 PM: ────────────────────────────────────────────────────────────────
12:32:57 PM: ​
12:32:57 PM: No Next.js cache to restore.
12:32:57 PM: Netlify configuration property “build.environment.NEXT_PRIVATE_TARGET” value changed.
12:32:57 PM: ​
12:32:57 PM: (@netlify/plugin-nextjs onPreBuild completed in 19ms)
12:32:57 PM: ​
12:32:57 PM: 2. Build command from Netlify app
12:32:57 PM: ────────────────────────────────────────────────────────────────
12:32:57 PM: ​
12:32:57 PM: $ npm run build
12:32:58 PM: > lawoffice@0.1.0 build
12:32:58 PM: > next build
12:32:58 PM: warn - Invalid next.config.js options detected:
12:32:58 PM: - The value at .images.remotePatterns[0].port must be 1 character or more but it was 0 characters.
12:32:58 PM: See more info here: invalid-next-config | Next.js
12:32:58 PM: warn - No build cache found. Please configure build caching for faster rebuilds. Read more: no-cache | Next.js
12:32:58 PM: info - Linting and checking validity of types…
12:32:59 PM: info - Creating an optimized production build…
12:33:13 PM: info - Compiled successfully
12:33:13 PM: info - Collecting page data…
12:33:22 PM: info - Generating static pages (0/31)
12:33:25 PM: info - Generating static pages (7/31)
12:33:26 PM: info - Generating static pages (15/31)
12:33:26 PM: Error occurred prerendering page “/blog/post-nine”. Read more: prerender-error | Next.js
12:33:26 PM: Error: Too many requests, retry after 541ms.: {“response”:{“errors”:[{“message”:“Too many requests, retry after 541ms.”,“extensions”:{“code”:“REQUESTS_EXCEEDED”,“limit”:15,“reset”:“2023-01-27T18:33:26.941Z”}}],“status”:429,“headers”:{}},“request”:{“query”:“\n query BlogPost($slug: String!) {\n blog {\n blog_posts(filter: { slug: { _contains: $slug } }) {\n title\n slug\n category\n excerpt\n content\n featured_image {\n id\n }\n author {\n name\n photo {\n id\n }\n }\n publication_date\n }\n }\n }\n”,“variables”:{“slug”:“post-nine”}}}
12:33:26 PM: at /opt/build/repo/node_modules/graphql-request/dist/index.js:395:31
12:33:26 PM: at step (/opt/build/repo/node_modules/graphql-request/dist/index.js:63:23)
12:33:26 PM: at Object.next (/opt/build/repo/node_modules/graphql-request/dist/index.js:44:53)
12:33:26 PM: at fulfilled (/opt/build/repo/node_modules/graphql-request/dist/index.js:35:58)
12:33:26 PM: at processTicksAndRejections (node:internal/process/task_queues:96:5)
12:33:26 PM: {
12:33:26 PM: title: ‘Terms of Service’,
12:33:26 PM: pre_title: ‘Legal Info’,
12:33:26 PM: content: ‘

Terms of Service

\n’ +
12:33:26 PM: ‘

Last updated: [insert current date]

\n’ +
12:33:26 PM: ‘

Please read these terms of service (“Terms”, “Terms of Service”) carefully before using the [website/application/service] operated by [Company Name] (“us”, “we”, or “our”).

\n’ +
12:33:26 PM: ‘

Your access to and use of the Service is conditioned on your acceptance of and compliance with these Terms. These Terms apply to all visitors, users and others who access or use the Service.

\n’ +
12:33:26 PM: ‘

By accessing or using the Service you agree to be bound by these Terms. If you disagree with any part of the terms then you may not access the Service.

\n’ +
12:33:26 PM: ‘

[Optional: If you create an account with us, you must provide us information that is accurate, complete, and current at all times. Failure to do so constitutes a breach of the Terms, which may result in immediate termination of your account on our Service.]

\n’ +
12:33:26 PM: ‘

Our Service may contain links to third-party web sites or services that are not owned or controlled by [Company Name]. [Company Name] has no control over, and assumes no responsibility for, the content, privacy policies, or practices of any third party web sites or services. You further acknowledge and agree that [Company Name] shall not be responsible or liable, directly or indirectly, for any damage or loss caused or alleged to be caused by or in connection with use of or reliance on any such content, goods or services available on or through any such web sites or services.

\n’ +
12:33:26 PM: ‘

We reserve the right, at our sole discretion, to modify or replace these Terms at any time. If a revision is material we will try to provide at least 30 days notice prior to any new terms taking effect. What constitutes a material change will be determined at our sole discretion.

\n’ +
12:33:26 PM: ‘

By continuing to access or use our Service after those revisions become effective, you agree to be bound by the revised terms. If you do not agree to the new terms, please stop using the Service.

\n’ +
12:33:26 PM: ‘

[Optional: If you have any questions about these Terms, please contact us.]


12:33:26 PM: }
12:33:27 PM: info - Generating static pages (23/31)
12:33:27 PM: info - Generating static pages (31/31)
12:33:27 PM: > Build error occurred
12:33:27 PM: Error: Export encountered errors on following paths:
12:33:27 PM: /blog/[slug]: /blog/post-nine
12:33:27 PM: at /opt/build/repo/node_modules/next/dist/export/index.js:408:19
12:33:27 PM: at runMicrotasks ()
12:33:27 PM: at processTicksAndRejections (node:internal/process/task_queues:96:5)
12:33:27 PM: at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:79:20)
12:33:27 PM: at async /opt/build/repo/node_modules/next/dist/build/index.js:1342:21
12:33:27 PM: at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:79:20)
12:33:27 PM: at async /opt/build/repo/node_modules/next/dist/build/index.js:1202:17
12:33:27 PM: at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:79:20)
12:33:27 PM: at async Object.build [as default] (/opt/build/repo/node_modules/next/dist/build/index.js:65:29)
12:33:28 PM: ​
12:33:28 PM: “build.command” failed
12:33:28 PM: ────────────────────────────────────────────────────────────────
12:33:28 PM: ​
12:33:28 PM: Error message
12:33:28 PM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
12:33:28 PM: ​
12:33:28 PM: Error location
12:33:28 PM: In Build command from Netlify app:
12:33:28 PM: npm run build
12:33:28 PM: ​
12:33:28 PM: Resolved config
12:33:28 PM: build:
12:33:28 PM: command: npm run build
12:33:28 PM: commandOrigin: ui
12:33:28 PM: environment:
12:33:28 PM: - NEXT_PUBLIC_ASSETS_URL
12:33:28 PM: - NEXT_PUBLIC_FE_URL
12:33:28 PM: - NEXT_PUBLIC_GRAPHQL
12:33:28 PM: - NEXT_PUBLIC_MAPBOX_API_TOKEN
12:33:28 PM: - NEXT_PRIVATE_TARGET
12:33:28 PM: publish: /opt/build/repo/.next
12:33:28 PM: publishOrigin: ui
12:33:28 PM: plugins:
12:33:28 PM: - inputs: {}
12:33:28 PM: origin: ui
12:33:28 PM: package: ‘@netlify/plugin-nextjs’
12:33:29 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
12:33:28 PM: Caching artifacts
12:33:28 PM: Started saving node modules
12:33:28 PM: Finished saving node modules
12:33:28 PM: Started saving build plugins
12:33:28 PM: Finished saving build plugins
12:33:28 PM: Started saving pip cache
12:33:28 PM: Finished saving pip cache
12:33:28 PM: Started saving emacs cask dependencies
12:33:28 PM: Finished saving emacs cask dependencies
12:33:28 PM: Started saving maven dependencies
12:33:28 PM: Finished saving maven dependencies
12:33:28 PM: Started saving boot dependencies
12:33:28 PM: Finished saving boot dependencies
12:33:28 PM: Started saving rust rustup cache
12:33:28 PM: Finished saving rust rustup cache
12:33:28 PM: Started saving go dependencies
12:33:28 PM: Finished saving go dependencies
12:33:29 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:33:29 PM: Failing build: Failed to build site
12:33:29 PM: Finished processing build request in 54.725s

Hi @mardirosianlaw :wave:t6: ,

Welcome to the forums. Please give this resource a read.

Can you also confirm the following:

  • does it work locally?
  • Repo/build log
1 Like

It is building locally and apparently it is building on netlify now as well…but intermittently (meaning it doesn’t build on every redeploy like it should).

^ That looks like the actual error.

Do you have any idea what would be causing a “Too many requests” error to thrown in relation to querying blog posts?

1 Like

my directory structure is as follows:
pages
- blog (directory)
– category (directory)
— [category_name].jsx (category archive)
– posts (directory)
— [page_index].jsx (pagination for blog archive)
– [slug].jsx (individual blog posts)
– index.jsx (blog archive page)
- services (directory)
– [link].jsx
- _app.jsx
- 404.jsx
- about.jsx
- index.jsx

  • additional individual pages at page root level (privacy policy, security, tos etc)

I am wondering if my issue could be the blog archive page? As you can see from the code below I am importing the [page_index].jsx and then exporting it in order to make the blog archive page the default (initial page for pagination). Then the /posts/[page_index].jsx are the subsequent pages in the pagination.

But this doesn’t ring true because the same issue seems to occur with the services director and dynamic services [link].jsx?


import { getStaticProps } from ‘./posts/[page_index]’

import Blog from ‘./posts/[page_index]’

export { getStaticProps }

export default Blog


I’m not sure if your repose answers the above question, @mardirosianlaw. As mentioned above, you’re getting a 429 from the destination server you’re trying to connect to. You might want to try raising the concern with them and get your API rate limit raised or something.

1 Like

Ahhh…I see what you mean. Thanks!

Hi I hope this helped!

1 Like

It did…Directus is throttling the free version of their app with hard limits on the data. Need to upgrade to a paid Directus Cloud Account (given that I used their free cloud instead of a local build). Thank You!

1 Like