Nextjs blog with headless CMS deployment problem

2:49:27 PM: Waiting for other deploys from your team to complete. Check the queue: https://app.netlify.com/teams/mur4tk4y4/builds
2:49:29 PM: build-image version: a2d22d22e4555d1ef0a972ed14a0a4b366ad20c4 (focal)
2:49:29 PM: build-image tag: v4.16.3
2:49:29 PM: buildbot version: 4033cea21a3d9a6b51a0c8660e8b7502a7f7abfe
2:49:29 PM: Fetching cached dependencies
2:49:29 PM: Failed to fetch cache, continuing with build
2:49:29 PM: Starting to prepare the repo for build
2:49:30 PM: No cached dependencies found. Cloning fresh repo
2:49:30 PM: git clone --filter=blob:none https://github.com/mur4tk4y4/cms-blog
2:49:31 PM: Preparing Git Reference refs/heads/main
2:49:31 PM: Parsing package.json dependencies
2:49:32 PM: Starting build script
2:49:32 PM: Installing dependencies
2:49:32 PM: Python version set to 2.7
2:49:33 PM: v16.19.0 is already installed.
2:49:33 PM: Now using node v16.19.0 (npm v8.19.3)
2:49:33 PM: Enabling Node.js Corepack
2:49:33 PM: Started restoring cached build plugins
2:49:33 PM: Finished restoring cached build plugins
2:49:33 PM: Attempting Ruby version 2.7.2, read from environment
2:49:34 PM: Using Ruby version 2.7.2
2:49:34 PM: Using PHP version 8.0
2:49:34 PM: Started restoring cached corepack dependencies
2:49:34 PM: mv: cannot move '/opt/build/cache/.node/corepack' to '/opt/buildhome/.node/corepack': No such file or directory
2:49:34 PM: Finished restoring cached corepack dependencies
2:49:34 PM: No npm workspaces detected
2:49:34 PM: Started restoring cached node modules
2:49:34 PM: Finished restoring cached node modules
2:49:34 PM: Bypassing sha validation. Running pre & post install scripts
2:49:35 PM: Installing npm packages using npm version 8.19.3
2:49:39 PM: added 124 packages, and audited 125 packages in 4s
2:49:39 PM: 27 packages are looking for funding
2:49:39 PM:   run `npm fund` for details
2:49:39 PM: found 0 vulnerabilities
2:49:39 PM: npm packages installed
2:49:39 PM: Started restoring cached go cache
2:49:39 PM: Finished restoring cached go cache
2:49:39 PM: go version go1.19.4 linux/amd64
2:49:39 PM: Detected 1 framework(s)
2:49:39 PM: "next" at version "13.1.2"
2:49:39 PM: Installing missing commands
2:49:39 PM: Verify run directory
2:49:39 PM: Section completed: initializing
2:49:41 PM: ​
2:49:41 PM:   Netlify Build                                                 
2:49:41 PM: ────────────────────────────────────────────────────────────────
2:49:41 PM: ​
2:49:41 PM: ❯ Version
2:49:41 PM:   @netlify/build 29.4.5
2:49:41 PM: ​
2:49:41 PM: ❯ Flags
2:49:41 PM:   baseRelDir: true
2:49:41 PM:   buildId: 63c539c7a4f89600522d1d51
2:49:41 PM:   deployId: 63c539c7a4f89600522d1d53
2:49:41 PM: ​
2:49:41 PM: ❯ Current directory
2:49:41 PM:   /opt/build/repo
2:49:41 PM: ​
2:49:41 PM: ❯ Config file
2:49:41 PM:   No config file was defined: using default values.
2:49:41 PM: ​
2:49:41 PM: ❯ Context
2:49:41 PM:   production
2:49:41 PM: ​
2:49:41 PM: ❯ Installing plugins
2:49:41 PM:    - @netlify/plugin-nextjs@4.29.4
2:49:49 PM: ​
2:49:49 PM: ❯ Using Next.js Runtime - v4.29.4
2:49:50 PM: ​
2:49:50 PM:   1. @netlify/plugin-nextjs (onPreBuild event)                  
2:49:50 PM: ────────────────────────────────────────────────────────────────
2:49:50 PM: ​
2:49:50 PM: No Next.js cache to restore.
2:49:50 PM: Netlify configuration property "build.environment.NEXT_PRIVATE_TARGET" value changed.
2:49:50 PM: ​
2:49:50 PM: (@netlify/plugin-nextjs onPreBuild completed in 14ms)
2:49:50 PM: ​
2:49:50 PM:   2. Build command from Netlify app                             
2:49:50 PM: ────────────────────────────────────────────────────────────────
2:49:50 PM: ​
2:49:50 PM: $ npm run build
2:49:50 PM: > build
2:49:50 PM: > next build
2:49:51 PM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
2:49:51 PM: info  - Linting and checking validity of types...
2:49:51 PM: error - ESLint must be installed in order to run during builds: npm install --save-dev eslint
2:49:54 PM: Failed to compile.
2:49:54 PM: 
2:49:54 PM: ./pages/_app.tsx:8:18
2:49:54 PM: Type error: Binding element 'Component' implicitly has an 'any' type.
2:49:54 PM:    6 | import { Layout } from '../components';
2:49:54 PM:    7 | 
2:49:54 PM: >  8 | function MyApp({ Component, pageProps }) {
2:49:54 PM:      |                  ^
2:49:54 PM:    9 |   return (
2:49:54 PM:   10 |     <Layout>
2:49:54 PM:   11 |       <Component {...pageProps} />
2:49:54 PM: ​
2:49:54 PM:   "build.command" failed                                        
2:49:54 PM: ────────────────────────────────────────────────────────────────
2:49:54 PM: ​
2:49:54 PM:   Error message
2:49:54 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
2:49:54 PM: ​
2:49:54 PM:   Error location
2:49:54 PM:   In Build command from Netlify app:
2:49:54 PM:   npm run build
2:49:54 PM: ​
2:49:54 PM:   Resolved config
2:49:54 PM:   build:
2:49:54 PM:     command: npm run build
2:49:54 PM:     commandOrigin: ui
2:49:54 PM:     environment:
2:49:54 PM:       - GRAPHCMS_TOKEN
2:49:54 PM:       - NEXT_PUBLIC_GRAPHCMS_ENDPOINT
2:49:54 PM:       - NEXT_PRIVATE_TARGET
2:49:54 PM:     publish: /opt/build/repo/.next
2:49:54 PM:     publishOrigin: ui
2:49:55 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
2:49:54 PM:   plugins:
2:49:54 PM:     - inputs: {}
2:49:54 PM:       origin: ui
2:49:54 PM:       package: '@netlify/plugin-nextjs'
2:49:54 PM: Caching artifacts
2:49:54 PM: Started saving node modules
2:49:54 PM: Finished saving node modules
2:49:54 PM: Started saving build plugins
2:49:54 PM: Finished saving build plugins
2:49:54 PM: Started saving pip cache
2:49:55 PM: Finished saving pip cache
2:49:55 PM: Started saving emacs cask dependencies
2:49:55 PM: Finished saving emacs cask dependencies
2:49:55 PM: Started saving maven dependencies
2:49:55 PM: Finished saving maven dependencies
2:49:55 PM: Started saving boot dependencies
2:49:55 PM: Finished saving boot dependencies
2:49:55 PM: Started saving rust rustup cache
2:49:55 PM: Finished saving rust rustup cache
2:49:55 PM: Started saving go dependencies
2:49:55 PM: Finished saving go dependencies
2:49:55 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:49:55 PM: Failing build: Failed to build site
2:49:55 PM: Finished processing build request in 26.019877432s

I try to deploy my nextjs blog to netlify but got some errors. It works on localhost flawlessly but even i try may ways could not solve. Please help

Hi @mur4tk4y4 welcome to the forums! :wave:t6:

Thanks you for reaching out and welcome to the Netlify Forums. First, have you looked through this resource 7? It is a compilation of all of our build and deploy resources. This is a good starting point.

If those resources don’t get you on the right track, can you share a bit more information about what you are trying to accomplish?

Lastly, please share these additional details so we can look into your experience further:

  • the name of your build instance: β€œexample-jones.netlify.com 1”
  • your project repo
  • what you have already tried
  • any error messages you have received in your terminal window or in the developer console
1 Like

Does the next build command work flawlessly on localhost? Here’s a pretty elaborate article related to your typescript issue:

1 Like

Hi @tomrutgers :wave:t6:

Thanks for the engagement and providing the article. I hope it helps you @mur4tk4y4

1 Like

I found out that the tutorials i watched ar all outdated and nextjs 13 came with many fundamental updates. I decided to build my project from scratch. As an absolute beginner i have learned so much from this case. Thanks for your support

@mur4tk4y4 that’s awesome to hear and i’m glad you learned something new. That’s great to hear. Can’t wait to see what your new project will be. Good luck! :rocket: :netliconfetti: