Netlify NextJS Build failed

I have problem with build. Kindly check this one. Any help is appreciated

10:27:41 AM: ​
10:27:41 AM: ────────────────────────────────────────────────────────────────
10:27:41 AM: Netlify Build
10:27:41 AM: ────────────────────────────────────────────────────────────────
10:27:41 AM: ​
10:27:41 AM: ❯ Version
10:27:41 AM: @netlify/build 27.18.4
10:27:41 AM: ​
10:27:41 AM: ❯ Flags
10:27:41 AM: baseRelDir: true
10:27:41 AM: buildId: 632d195c3890861892f426fc
10:27:41 AM: deployId: 632d195c3890861892f426fe
10:27:41 AM: ​
10:27:41 AM: ❯ Current directory
10:27:41 AM: /opt/build/repo
10:27:41 AM: ​
10:27:41 AM: ❯ Config file
10:27:41 AM: No config file was defined: using default values.
10:27:41 AM: ​
10:27:41 AM: ❯ Context
10:27:41 AM: production
10:27:41 AM: ​
10:27:41 AM: ❯ Using Next.js Runtime - v4.23.1
10:27:42 AM: ​
10:27:42 AM: ────────────────────────────────────────────────────────────────
10:27:42 AM: 1. @netlify/plugin-nextjs (onPreBuild event)
10:27:42 AM: ────────────────────────────────────────────────────────────────
10:27:42 AM: ​
10:27:42 AM: No Next.js cache to restore.
10:27:42 AM: Netlify configuration property “build.environment.NEXT_PRIVATE_TARGET” value changed.
10:27:42 AM: ​
10:27:42 AM: (@netlify/plugin-nextjs onPreBuild completed in 14ms)
10:27:42 AM: ​
10:27:42 AM: ────────────────────────────────────────────────────────────────
10:27:42 AM: 2. Build command from Netlify app
10:27:42 AM: ────────────────────────────────────────────────────────────────
10:27:42 AM: ​
10:27:42 AM: $ CI=‘’ npm run build
10:27:43 AM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
10:27:43 AM: npm WARN config location in the cache, and they are managed by
10:27:43 AM: npm WARN config cacache.
10:27:43 AM: > nextjs-penowi@0.1.0 build
10:27:43 AM: > next build
10:27:43 AM: warn - No build cache found. Please configure build caching for faster rebuilds. Read more: no-cache | Next.js
10:27:43 AM: info - Linting and checking validity of types…
10:27:47 AM: info - Creating an optimized production build…
10:27:47 AM: info - Disabled SWC as replacement for Babel because of custom Babel configuration “.babelrc” swc-disabled | Next.js
10:27:48 AM: info - Using external babel configuration from /opt/build/repo/.babelrc
10:27:54 AM: info - Compiled successfully
10:27:54 AM: info - Collecting page data…
10:27:57 AM: > Build optimization failed: found pages without a React Component as default export in
10:27:57 AM: pages/Mens/index.styled
10:27:57 AM: pages/Womens/index.styled
10:27:57 AM: pages/Home/index.styled
10:27:57 AM: pages/Kids/index.styled
10:27:57 AM: pages/AboutUs/index.styled
10:27:57 AM: See page-without-valid-component | Next.js for more info.
10:27:57 AM: ​
10:27:57 AM: ────────────────────────────────────────────────────────────────
10:27:57 AM: “build.command” failed
10:27:57 AM: ────────────────────────────────────────────────────────────────
10:27:57 AM: ​
10:27:57 AM: Error message
10:27:57 AM: Command failed with exit code 1: CI=‘’ npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
10:27:57 AM: ​
10:27:57 AM: Error location
10:27:57 AM: In Build command from Netlify app:
10:27:57 AM: CI=‘’ npm run build
10:27:57 AM: ​
10:27:57 AM: Resolved config
10:27:57 AM: build:
10:27:57 AM: command: CI=‘’ npm run build
10:27:57 AM: commandOrigin: ui
10:27:57 AM: environment:
10:27:57 AM: - CI
10:27:57 AM: - NEXT_PRIVATE_TARGET
10:27:57 AM: publish: /opt/build/repo/_next
10:27:57 AM: publishOrigin: ui
10:27:57 AM: plugins:
10:27:57 AM: - inputs: {}
10:27:57 AM: origin: ui
10:27:57 AM: package: ‘@netlify/plugin-nextjs’
10:27:57 AM: Caching artifacts
10:27:57 AM: Started saving node modules
10:27:57 AM: Finished saving node modules
10:27:57 AM: Started saving build plugins
10:27:58 AM: Finished saving build plugins
10:27:58 AM: Started saving pip cache
10:27:58 AM: Finished saving pip cache
10:27:58 AM: Started saving emacs cask dependencies
10:27:58 AM: Finished saving emacs cask dependencies
10:27:58 AM: Started saving maven dependencies
10:27:58 AM: Finished saving maven dependencies
10:27:58 AM: Started saving boot dependencies
10:27:58 AM: Finished saving boot dependencies
10:27:58 AM: Started saving rust rustup cache
10:27:58 AM: Finished saving rust rustup cache
10:27:58 AM: Started saving go dependencies
10:27:58 AM: Finished saving go dependencies
10:28:00 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:28:00 AM: Creating deploy upload records
10:28:00 AM: Failing build: Failed to build site
10:28:00 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
10:28:00 AM: Finished processing build request in 36.943673265s

Hi there, glad you found us :wave: before we can help you, we need a little more information on the issues you are facing.

First, have you looked through this resource? It is a compilation of all of our build and deploy resources. This is a good starting point.

If you have worked through those guides and are still encountering issues please share the following information:

  • the name of your build instance: “example-jones.netlify.com
  • what you have already tried
  • any error messages you have received in your terminal window or in the developer console