Home
Support Forums

NextJs Deployment Issue

I have troubles deploying my nextjs app on netlify

This is how my netlify.toml file looks like:

[build]
  command = "npm run build"
  publish = "out"

This is the whole deployment output with the errors:

3:02:53 PM: Build ready to start
3:02:55 PM: build-image version: fa439ad1ab9393b2c0d449d8d7c033927683f4b0
3:02:55 PM: build-image tag: v4.3.0
3:02:55 PM: buildbot version: 1ed4041128c7c024b4c4b72e2ad30a0740c570a7
3:02:55 PM: Building without cache
3:02:55 PM: Starting to prepare the repo for build
3:02:55 PM: No cached dependencies found. Cloning fresh repo
3:02:55 PM: git clone https://github.com/28development/persona_imo
3:02:56 PM: Preparing Git Reference refs/heads/main
3:02:57 PM: Parsing package.json dependencies
3:02:57 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'npm run build' versus 'next build' in the Netlify UI
3:02:57 PM: Starting build script
3:02:57 PM: Installing dependencies
3:02:57 PM: Python version set to 2.7
3:02:58 PM: Downloading and installing node v16.8.0...
3:02:58 PM: Downloading https://nodejs.org/dist/v16.8.0/node-v16.8.0-linux-x64.tar.xz...
3:02:59 PM: Computing checksum with sha256sum
3:02:59 PM: Checksums matched!
3:03:02 PM: Now using node v16.8.0 (npm v7.21.0)
3:03:02 PM: Started restoring cached build plugins
3:03:02 PM: Finished restoring cached build plugins
3:03:02 PM: Attempting ruby version 2.7.2, read from environment
3:03:03 PM: Using ruby version 2.7.2
3:03:04 PM: Using PHP version 8.0
3:03:04 PM: Started restoring cached node modules
3:03:04 PM: Finished restoring cached node modules
3:03:04 PM: Installing NPM modules using NPM version 7.21.0
3:03:16 PM: npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
3:03:25 PM: npm WARN deprecated @types/vfile-message@2.0.0: This is a stub types definition. vfile-message provides its own type definitions, so you do not need this installed.
3:03:26 PM: npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
3:03:26 PM: npm WARN deprecated @hapi/pinpoint@1.0.2: Moved to 'npm install @sideway/pinpoint'
3:03:26 PM: npm WARN deprecated @hapi/formula@1.2.0: Moved to 'npm install @sideway/formula'
3:03:27 PM: npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
3:03:28 PM: npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
3:03:29 PM: npm WARN deprecated @hapi/boom@7.4.11: This version has been deprecated and is no longer supported or maintained
3:03:29 PM: npm WARN deprecated @hapi/wreck@15.1.0: This version has been deprecated and is no longer supported or maintained
3:03:30 PM: npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
3:03:30 PM: npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
3:03:30 PM: npm WARN deprecated @hapi/joi@16.1.8: Switch to 'npm install joi'
3:03:30 PM: npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
3:04:03 PM: > personaimo@1.1.0 prepare
3:04:03 PM: > husky install
3:04:03 PM: husky - Git hooks installed
3:04:03 PM: added 1612 packages, and audited 1613 packages in 59s
3:04:03 PM: 72 packages are looking for funding
3:04:03 PM:   run `npm fund` for details
3:04:03 PM: 6 high severity vulnerabilities
3:04:03 PM: To address issues that do not require attention, run:
3:04:03 PM:   npm audit fix
3:04:03 PM: Some issues need review, and may require choosing
3:04:03 PM: a different dependency.
3:04:03 PM: Run `npm audit` for details.
3:04:03 PM: NPM modules installed
3:04:04 PM: Started restoring cached go cache
3:04:04 PM: Finished restoring cached go cache
3:04:04 PM: go version go1.16.5 linux/amd64
3:04:04 PM: go version go1.16.5 linux/amd64
3:04:04 PM: Installing missing commands
3:04:04 PM: Verify run directory
3:04:05 PM: ​
3:04:05 PM: ────────────────────────────────────────────────────────────────
3:04:05 PM:   Netlify Build                                                 
3:04:05 PM: ────────────────────────────────────────────────────────────────
3:04:05 PM: ​
3:04:05 PM: ❯ Version
3:04:05 PM:   @netlify/build 18.7.3
3:04:05 PM: ​
3:04:05 PM: ❯ Flags
3:04:05 PM:   baseRelDir: true
3:04:05 PM:   buildId: 61336e7ddf6ebfa40522f9e5
3:04:05 PM:   deployId: 61336e7ddf6ebfa40522f9e7
3:04:05 PM: ​
3:04:05 PM: ❯ Current directory
3:04:05 PM:   /opt/build/repo
3:04:05 PM: ​
3:04:05 PM: ❯ Config file
3:04:05 PM:   /opt/build/repo/netlify.toml
3:04:05 PM: ​
3:04:05 PM: ❯ Context
3:04:05 PM:   production
3:04:05 PM: ​
3:04:05 PM: ❯ Installing plugins
3:04:05 PM:    - @netlify/plugin-nextjs@3.9.0
3:04:16 PM: ​
3:04:16 PM: ❯ Loading plugins
3:04:16 PM:    - @netlify/plugin-nextjs@3.9.0 from Netlify app
3:04:17 PM: ​
3:04:17 PM: ────────────────────────────────────────────────────────────────
3:04:17 PM:   1. onPreBuild command from @netlify/plugin-nextjs             
3:04:17 PM: ────────────────────────────────────────────────────────────────
3:04:17 PM: ​
3:04:17 PM: Using Next.js 11.1.0
3:04:17 PM: Warning: support for Next.js >=11.1.0 is experimental
3:04:17 PM: info  - Loaded env from /opt/build/repo/.env
3:04:17 PM: info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
3:04:17 PM: warn  - You have enabled experimental feature(s).
3:04:17 PM: warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.
3:04:18 PM: No Next.js cache to restore.
3:04:18 PM: ​
3:04:18 PM: (@netlify/plugin-nextjs onPreBuild completed in 862ms)
3:04:18 PM: ​
3:04:18 PM: ────────────────────────────────────────────────────────────────
3:04:18 PM:   2. build.command from netlify.toml                            
3:04:18 PM: ────────────────────────────────────────────────────────────────
3:04:18 PM: ​
3:04:18 PM: $ npm run build
3:04:18 PM: > personaimo@1.1.0 build
3:04:18 PM: > next build
3:04:19 PM: info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
3:04:19 PM: warn  - You have enabled experimental feature(s).
3:04:19 PM: warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.
3:04:19 PM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
3:04:19 PM: info  - Checking validity of types...
3:04:24 PM: info  - Creating an optimized production build...
3:04:31 PM: warn - You have enabled the JIT engine which is currently in preview.
3:04:31 PM: warn - Preview features are not covered by semver, may introduce breaking changes, and can change at any time.
3:04:51 PM: (node:1823) [DEP_WEBPACK_CHUNK_HAS_ENTRY_MODULE] DeprecationWarning: Chunk.hasEntryModule: Use new ChunkGraph API
3:04:51 PM: (Use `node --trace-deprecation ...` to show where the warning was created)
3:04:51 PM: (node:1823) [DEP_WEBPACK_CHUNK_ADD_MODULE] DeprecationWarning: Chunk.addModule: Use new ChunkGraph API
3:04:54 PM: warn  - Compiled with warnings
3:04:54 PM: ./node_modules/keyv/src/index.js
3:04:54 PM: Critical dependency: the request of a dependency is an expression
3:04:54 PM: ./node_modules/next/dist/server/load-components.js
3:04:54 PM: Critical dependency: the request of a dependency is an expression
3:04:54 PM: ./node_modules/next/dist/server/load-components.js
3:04:54 PM: Critical dependency: the request of a dependency is an expression
3:04:54 PM: ./node_modules/next/dist/server/load-components.js
3:04:54 PM: Critical dependency: the request of a dependency is an expression
3:04:54 PM: ./node_modules/next/dist/server/require.js
3:04:54 PM: Critical dependency: the request of a dependency is an expression
3:04:54 PM: ./node_modules/next/dist/server/require.js
3:04:54 PM: Critical dependency: the request of a dependency is an expression
3:04:54 PM: ./node_modules/next/dist/server/require.js
3:04:54 PM: Critical dependency: the request of a dependency is an expression
3:04:54 PM: info  - Collecting page data...
3:04:58 PM: info  - Generating static pages (0/12)
3:05:02 PM: [{"slug":"haus-am-see-dortmund","title":"Haus Am See Dortmund","date":"2021-08-22T00:00:00.000Z","galleryImages":["/img/avatar.png"],"tag":["Haus","See"],"tags":["Haus","See"]},{"slug":"haus-am-see-essen","title":"Haus Am See Essen","date":"2021-08-22T00:00:00.000Z","galleryImages":["/img/avatar.png"],"tag":["Haus","See"],"tags":["Haus","See"]}]
3:05:02 PM: info  - Generating static pages (3/12)
3:05:02 PM: info  - Generating static pages (6/12)
3:05:03 PM: info  - Generating static pages (9/12)
3:05:04 PM: info  - Generating static pages (12/12)
3:05:04 PM: info  - Finalizing page optimization...
3:05:04 PM: Page                                               Size     First Load JS
3:05:04 PM: ┌ ● / (3707 ms)                                    2.12 kB        42.7 kB
3:05:04 PM: ├   /_app                                          0 B            40.6 kB
3:05:04 PM: ├ ○ /404 (571 ms)                                  703 B          41.3 kB
3:05:04 PM: ├ ● /about (3841 ms)                               346 B          50.1 kB
3:05:04 PM: ├ ○ /projects (609 ms)                             2.47 kB        46.5 kB
3:05:04 PM: ├ ● /real-estate (2994 ms)                         3.27 kB        47.3 kB
3:05:04 PM: ├ ● /real-estate/[...slug] (3151 ms)               536 B          50.3 kB
3:05:04 PM: ├   ├ /real-estate/haus-am-see-essen (1656 ms)
3:05:04 PM: ├   └ /real-estate/haus-am-see-dortmund (1495 ms)
3:05:04 PM: ├ ● /real-estate/page/[page] (3186 ms)             3.24 kB        47.3 kB
3:05:04 PM: ├   └ /real-estate/page/1 (3186 ms)
3:05:04 PM: ├ ● /tags (3086 ms)                                1.86 kB        42.5 kB
3:05:04 PM: └ ● /tags/[tag] (5927 ms)                          3.25 kB        47.3 kB
3:05:04 PM:     ├ /tags/haus (3116 ms)
3:05:04 PM:     └ /tags/see (2811 ms)
3:05:04 PM: + First Load JS shared by all                      40.6 kB
3:05:04 PM:   ├ chunks/main.e5a452.js                          30.7 kB
3:05:04 PM:   ├ chunks/pages/_app.e0d974.js                    9.04 kB
3:05:04 PM:   ├ chunks/webpack.ddd010.js                       822 B
3:05:04 PM:   └ css/0d5aca6fb15257a916bf.css                   6.41 kB
3:05:04 PM: λ  (Lambda)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
3:05:04 PM: ○  (Static)  automatically rendered as static HTML (uses no initial props)
3:05:04 PM: ●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
3:05:04 PM:    (ISR)     incremental static regeneration (uses revalidate in getStaticProps)
3:05:04 PM: ​
3:05:04 PM: (build.command completed in 46.2s)
3:05:04 PM: ​
3:05:04 PM: ────────────────────────────────────────────────────────────────
3:05:04 PM:   3. onBuild command from @netlify/plugin-nextjs                
3:05:04 PM: ────────────────────────────────────────────────────────────────
3:05:04 PM: ​
3:05:04 PM: Detected Next.js site. Copying files...
3:05:04 PM: ** Running Next on Netlify package **
3:05:04 PM: 🚀 Next on Netlify 🚀
3:05:04 PM: 🌍️ Copying public folder to /opt/build/repo/out
3:05:04 PM: 💼 Copying static NextJS assets to /opt/build/repo/out
3:05:04 PM: 💫 Setting up API endpoints as Netlify Functions in /opt/build/repo/.netlify/functions-internal
3:05:04 PM: 💫 Setting up pages with getInitialProps as Netlify Functions in /opt/build/repo/.netlify/functions-internal
3:05:04 PM: 💫 Setting up pages with getServerSideProps as Netlify Functions in /opt/build/repo/.netlify/functions-internal
3:05:04 PM: 🔥 Copying pre-rendered pages with getStaticProps and JSON data to /opt/build/repo/out
3:05:04 PM: 💫 Setting up pages with getStaticProps and fallback: true as Netlify Functions in /opt/build/repo/.netlify/functions-internal
3:05:04 PM: 💫 Setting up pages with getStaticProps and revalidation interval as Netlify Functions in /opt/build/repo/.netlify/functions-internal
3:05:04 PM: 🔥 Copying pre-rendered pages without props to /opt/build/repo/out
3:05:04 PM: Building 27 pages
3:05:04 PM: 🔀 Setting up redirects
3:05:04 PM: 🔀 Setting up headers
3:05:04 PM: ✅ Success! All done!
3:05:04 PM: ​
3:05:04 PM: (@netlify/plugin-nextjs onBuild completed in 228ms)
3:05:04 PM: ​
3:05:04 PM: ────────────────────────────────────────────────────────────────
3:05:04 PM:   4. Functions bundling                                         
3:05:04 PM: ────────────────────────────────────────────────────────────────
3:05:04 PM: ​
3:05:04 PM: Packaging Functions from .netlify/functions-internal directory:
3:05:04 PM:  - next_about/next_about.js
3:05:04 PM:  - next_image/next_image.js
3:05:04 PM:  - next_index/next_index.js
3:05:04 PM:  - next_realestate/next_realestate.js
3:05:04 PM:  - next_realestate_page_page/next_realestate_page_page.js
3:05:04 PM:  - next_realestate_slug/next_realestate_slug.js
3:05:04 PM:  - next_tags/next_tags.js
3:05:04 PM:  - next_tags_tag/next_tags_tag.js
3:05:04 PM: ​
3:05:06 PM: ​
3:05:06 PM: ────────────────────────────────────────────────────────────────
3:05:06 PM:   Internal error during "Functions bundling"                    
3:05:06 PM: ────────────────────────────────────────────────────────────────
3:05:06 PM: ​
3:05:06 PM:   Error message
3:05:06 PM:   Error: readdirp: root argument is required. Usage: readdirp(root, options)
3:05:06 PM: ​
3:05:06 PM:   Error location
3:05:06 PM:   During Functions bundling
3:05:06 PM:       at readdirp (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/readdirp/index.js:262:11)
3:05:06 PM:       at /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/readdirp/index.js:276:5
3:05:06 PM:       at new Promise (<anonymous>)
3:05:06 PM:       at Function.readdirpPromise [as promise] (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/readdirp/index.js:274:10)
3:05:06 PM:       at hasFunctionRootFile (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:119:32)
3:05:06 PM:       at lacksNodeModules (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:111:12)
3:05:06 PM:       at getModuleNotFoundMessage (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:50:43)
3:05:06 PM:       at getModuleNotFoundErrorObject (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:41:25)
3:05:06 PM:       at getModuleNotFoundErrorFromZISI (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:91:10)
3:05:06 PM:       at getModuleNotFoundError (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:27:31)
3:05:06 PM: ​
3:05:06 PM:   Resolved config
3:05:06 PM:   build:
3:05:06 PM:     command: npm run build
3:05:06 PM:     commandOrigin: config
3:05:06 PM:     publish: /opt/build/repo/out
3:05:06 PM:     publishOrigin: config
3:05:06 PM:   headers:
3:05:15 PM:     - for: /_next/static/chunks/*      values:        cache-control: public, max-age=31536000, immutable  plugins:    - inputs: {}      origin: ui      package: '@netlify/plugin-nextjs'  redirects:    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /      status: 200      to: /.netlify/functions/next_index    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /_next/data/HaG4Pbm9j8yEuDvG2jveW/about.json      status: 200      to: /.netlify/functions/next_about    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /_next/data/HaG4Pbm9j8yEuDvG2jveW/index.json      status: 200      to: /.netlify/functions/next_index    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /_next/data/HaG4Pbm9j8yEuDvG2jveW/real-estate.json      status: 200      to: /.netlify/functions/next_realestate    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /_next/data/HaG4Pbm9j8yEuDvG2jveW/real-estate/haus-am-see-dortmund.json      status: 200      to: /.netlify/functions/next_realestate_slug    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /_next/data/HaG4Pbm9j8yEuDvG2jveW/real-estate/haus-am-see-essen.json      status: 200      to: /.netlify/functions/next_realestate_slug    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /_next/data/HaG4Pbm9j8yEuDvG2jveW/real-estate/page/1.json      status: 200      to: /.netlify/functions/next_realestate_page_page    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /_next/data/HaG4Pbm9j8yEuDvG2jveW/tags.json      status: 200      to: /.netlify/functions/next_tags    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /_next/data/HaG4Pbm9j8yEuDvG2jveW/tags/haus.json      status: 200      to: /.netlify/functions/next_tags_tag    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /_next/data/HaG4Pbm9j8yEuDvG2jveW/tags/see.json      status: 200      to: /.netlify/functions/next_tags_tag    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /about      status: 200      to: /.netlify/functions/next_about    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /real-estate      status: 200      to: /.netlify/functions/next_realestate    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /real-estate/haus-am-see-dortmund      status: 200      to: /.netlify/functions/next_realestate_slug    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /real-estate/haus-am-see-essen      status: 200      to: /.netlify/functions/next_realestate_slug    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /real-estate/page/1      status: 200      to: /.netlify/functions/next_realestate_page_page    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /tags      status: 200      to: /.netlify/functions/next_tags    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /tags/haus      status: 200      to: /.netlify/functions/next_tags_tag    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /tags/see      status: 200      to: /.netlify/functions/next_tags_tag    - force: true      from: /_next/image*      query:        q: ':quality'        url: ':url'        w: ':width'      status: 301      to: /nextimg/:url/:width/:quality    - from: /nextimg/*      status: 200      to: /.netlify/functions/next_imageCaching artifacts
3:05:15 PM: Started saving node modules
3:05:15 PM: Finished saving node modules
3:05:15 PM: Started saving build plugins
3:05:15 PM: Finished saving build plugins
3:05:15 PM: Started saving pip cache
3:05:15 PM: Finished saving pip cache
3:05:15 PM: Started saving emacs cask dependencies
3:05:15 PM: Finished saving emacs cask dependencies
3:05:15 PM: Started saving maven dependencies
3:05:15 PM: Finished saving maven dependencies
3:05:15 PM: Started saving boot dependencies
3:05:15 PM: Finished saving boot dependencies
3:05:15 PM: Started saving rust rustup cache
3:05:15 PM: Finished saving rust rustup cache
3:05:15 PM: Started saving go dependencies
3:05:15 PM: Finished saving go dependencies
3:05:18 PM: Build failed due to an internal system error: Build script returned non-zero exit code: 4
3:05:18 PM: Creating deploy upload records
3:05:18 PM: Failing build: Failed to build site
3:05:18 PM: Failed during stage 'building site': Build script returned non-zero exit code: 4
3:05:18 PM: Finished processing build request in 2m23.674663786s

I seem to be having the same issue. One thing I don’t understand is why the error seems to be with the Functions building as I am only using getStaticProps and getStatipaths.

Here is my deployment log:

11:19:10 PM: Build ready to start
11:19:12 PM: build-image version: fa439ad1ab9393b2c0d449d8d7c033927683f4b0
11:19:12 PM: build-image tag: v4.3.0
11:19:12 PM: buildbot version: 1ed4041128c7c024b4c4b72e2ad30a0740c570a7
11:19:12 PM: Building without cache
11:19:12 PM: Starting to prepare the repo for build
11:19:12 PM: No cached dependencies found. Cloning fresh repo
11:19:12 PM: git clone git@gitlab.com:rockalingua/static-basic-page
11:19:15 PM: Preparing Git Reference refs/heads/main
11:19:16 PM: Parsing package.json dependencies
11:19:16 PM: Starting build script
11:19:17 PM: Installing dependencies
11:19:17 PM: Python version set to 2.7
11:19:17 PM: Downloading and installing node v16.8.0...
11:19:17 PM: Downloading https://nodejs.org/dist/v16.8.0/node-v16.8.0-linux-x64.tar.xz...
11:19:18 PM: Computing checksum with sha256sum
11:19:18 PM: Checksums matched!
11:19:21 PM: Now using node v16.8.0 (npm v7.21.0)
11:19:21 PM: Started restoring cached build plugins
11:19:21 PM: Finished restoring cached build plugins
11:19:21 PM: Attempting ruby version 2.7.2, read from environment
11:19:23 PM: Using ruby version 2.7.2
11:19:23 PM: Using PHP version 8.0
11:19:23 PM: Started restoring cached yarn cache
11:19:23 PM: Finished restoring cached yarn cache
11:19:23 PM: Installing yarn at version 1.22.10
11:19:23 PM: Installing Yarn!
11:19:23 PM: > Downloading tarball...
11:19:23 PM: [1/2]: https://yarnpkg.com/downloads/1.22.10/yarn-v1.22.10.tar.gz --> /tmp/yarn.tar.gz.RPLRjkyU1p
11:19:23 PM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
11:19:23 PM:                                  Dload  Upload   Total   Spent    Left  Speed
11:19:23 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
11:19:23 PM: 100    81  100    81    0     0    450      0 --:--:-- --:--:-- --:--:--   447
11:19:23 PM: 100    81  100    81    0     0    450      0 --:--:-- --:--:-- --:--:--   447
11:19:23 PM: 100    95  100    95    0     0    227      0 --:--:-- --:--:-- --:--:--   227
11:19:24 PM: 100   626  100   626    0     0   1081      0 --:--:-- --:--:-- --:--:--  1081
11:19:24 PM: 100 1215k  100 1215k    0     0  1660k      0 --:--:-- --:--:-- --:--:-- 1660k
11:19:24 PM: [2/2]: https://yarnpkg.com/downloads/1.22.10/yarn-v1.22.10.tar.gz.asc --> /tmp/yarn.tar.gz.RPLRjkyU1p.asc
11:19:24 PM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
11:19:24 PM:                                  Dload  Upload   Total   Spent    Left  Speed
11:19:24 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
11:19:24 PM: 100    85  100    85    0     0   1370      0 --:--:-- --:--:-- --:--:--  1370
11:19:24 PM: 100    99  100    99    0     0   1087      0 --:--:-- --:--:-- --:--:--  1087
11:19:24 PM: 100   630  100   630    0     0   3351      0 --:--:-- --:--:-- --:--:--  3351
11:19:24 PM: 100   832  100   832    0     0   3151      0 --:--:-- --:--:-- --:--:--  3151
11:19:24 PM: > Verifying integrity...
11:19:24 PM: gpg: Signature made Fri 02 Oct 2020 11:17:27 AM UTC
11:19:24 PM: gpg:                using RSA key 6D98490C6F1ACDDD448E45954F77679369475BAA
11:19:24 PM: gpg: Good signature from "Yarn Packaging <yarn@dan.cx>" [unknown]
11:19:24 PM: gpg: WARNING: This key is not certified with a trusted signature!
11:19:24 PM: gpg:          There is no indication that the signature belongs to the owner.
11:19:24 PM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
11:19:24 PM:      Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
11:19:24 PM: > GPG signature looks good
11:19:24 PM: > Extracting to ~/.yarn...
11:19:24 PM: > Adding to $PATH...
11:19:24 PM: > Successfully installed Yarn 1.22.10! Please open another terminal where the `yarn` command will now be available.
11:19:25 PM: No yarn workspaces detected
11:19:25 PM: Started restoring cached node modules
11:19:25 PM: Finished restoring cached node modules
11:19:25 PM: Installing NPM modules using Yarn version 1.22.10
11:19:26 PM: yarn install v1.22.10
11:19:26 PM: [1/4] Resolving packages...
11:19:26 PM: [2/4] Fetching packages...
11:19:38 PM: info @next/swc-darwin-arm64@11.1.2: The platform "linux" is incompatible with this module.
11:19:38 PM: info "@next/swc-darwin-arm64@11.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
11:19:38 PM: info @next/swc-darwin-arm64@11.1.2: The CPU architecture "x64" is incompatible with this module.
11:19:38 PM: info @next/swc-darwin-x64@11.1.2: The platform "linux" is incompatible with this module.
11:19:38 PM: info "@next/swc-darwin-x64@11.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
11:19:38 PM: info @next/swc-win32-x64-msvc@11.1.2: The platform "linux" is incompatible with this module.
11:19:38 PM: info "@next/swc-win32-x64-msvc@11.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
11:19:38 PM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
11:19:38 PM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
11:19:38 PM: [3/4] Linking dependencies...
11:19:38 PM: warning "next > styled-jsx > @babel/plugin-syntax-jsx@7.14.5" has unmet peer dependency "@babel/core@^7.0.0-0".
11:19:38 PM: warning "eslint-config-next > @typescript-eslint/parser > @typescript-eslint/typescript-estree > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
11:19:43 PM: [4/4] Building fresh packages...
11:19:43 PM: Done in 17.29s.
11:19:43 PM: NPM modules installed using Yarn
11:19:43 PM: Started restoring cached go cache
11:19:43 PM: Finished restoring cached go cache
11:19:43 PM: go version go1.16.5 linux/amd64
11:19:43 PM: go version go1.16.5 linux/amd64
11:19:43 PM: Installing missing commands
11:19:43 PM: Verify run directory
11:19:44 PM: ​
11:19:44 PM: ────────────────────────────────────────────────────────────────
11:19:44 PM:   Netlify Build                                                 
11:19:44 PM: ────────────────────────────────────────────────────────────────
11:19:44 PM: ​
11:19:44 PM: ❯ Version
11:19:44 PM:   @netlify/build 18.7.3
11:19:44 PM: ​
11:19:44 PM: ❯ Flags
11:19:44 PM:   baseRelDir: true
11:19:44 PM:   buildId: 6133f0dedf6ebf3cbb22fa02
11:19:44 PM:   deployId: 6133f0dedf6ebf3cbb22fa04
11:19:44 PM: ​
11:19:44 PM: ❯ Current directory
11:19:44 PM:   /opt/build/repo
11:19:44 PM: ​
11:19:44 PM: ❯ Config file
11:19:44 PM:   /opt/build/repo/netlify.toml
11:19:44 PM: ​
11:19:44 PM: ❯ Context
11:19:44 PM:   production
11:19:45 PM: ​
11:19:45 PM: ❯ Installing plugins
11:19:45 PM:    - @netlify/plugin-nextjs@3.9.0
11:19:53 PM: ​
11:19:53 PM: ❯ Loading plugins
11:19:53 PM:    - @netlify/plugin-nextjs@3.9.0 from Netlify app
11:19:54 PM: ​
11:19:54 PM: ────────────────────────────────────────────────────────────────
11:19:54 PM:   1. onPreBuild command from @netlify/plugin-nextjs             
11:19:54 PM: ────────────────────────────────────────────────────────────────
11:19:54 PM: ​
11:19:54 PM: Using Next.js 11.1.2
11:19:54 PM: Warning: support for Next.js >=11.1.0 is experimental
11:19:54 PM: info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
11:19:55 PM: No Next.js cache to restore.
11:19:55 PM: ​
11:19:55 PM: (@netlify/plugin-nextjs onPreBuild completed in 772ms)
11:19:55 PM: ​
11:19:55 PM: ────────────────────────────────────────────────────────────────
11:19:55 PM:   2. build.command from netlify.toml                            
11:19:55 PM: ────────────────────────────────────────────────────────────────
11:19:55 PM: ​
11:19:55 PM: $ npm run build
11:19:55 PM: > static-basic-page@0.1.0 build
11:19:55 PM: > next build
11:19:56 PM: info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
11:19:56 PM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
11:19:56 PM: info  - Checking validity of types...
11:20:00 PM: ./pages/videos/index.js
11:20:00 PM: 15:19  Warning: Do not use <img>. Use Image from 'next/image' instead. See https://nextjs.org/docs/messages/no-img-element.  @next/next/no-img-element
11:20:00 PM: 15:19  Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.  jsx-a11y/alt-text
11:20:00 PM: ./components/Footer.js
11:20:00 PM: 7:19  Warning: Do not use <img>. Use Image from 'next/image' instead. See https://nextjs.org/docs/messages/no-img-element.  @next/next/no-img-element
11:20:00 PM: info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
11:20:00 PM: info  - Creating an optimized production build...
11:20:18 PM: (node:1696) [DEP_WEBPACK_CHUNK_HAS_ENTRY_MODULE] DeprecationWarning: Chunk.hasEntryModule: Use new ChunkGraph API
11:20:18 PM: (Use `node --trace-deprecation ...` to show where the warning was created)
11:20:19 PM: warn  - Compiled with warnings
11:20:19 PM: ./node_modules/knex/lib/migrations/util/import-file.js
11:20:19 PM: Critical dependency: the request of a dependency is an expression
11:20:19 PM: ./node_modules/knex/lib/migrations/util/import-file.js
11:20:19 PM: Critical dependency: the request of a dependency is an expression
11:20:19 PM: ./node_modules/next/dist/server/load-components.js
11:20:19 PM: Critical dependency: the request of a dependency is an expression
11:20:19 PM: ./node_modules/next/dist/server/load-components.js
11:20:19 PM: Critical dependency: the request of a dependency is an expression
11:20:19 PM: ./node_modules/next/dist/server/load-components.js
11:20:19 PM: Critical dependency: the request of a dependency is an expression
11:20:19 PM: ./node_modules/next/dist/server/require.js
11:20:19 PM: Critical dependency: the request of a dependency is an expression
11:20:19 PM: ./node_modules/next/dist/server/require.js
11:20:19 PM: Critical dependency: the request of a dependency is an expression
11:20:19 PM: ./node_modules/next/dist/server/require.js
11:20:19 PM: Critical dependency: the request of a dependency is an expression
11:20:19 PM: info  - Collecting page data...
11:20:20 PM: info  - Generating static pages (0/76)
11:20:23 PM: info  - Generating static pages (19/76)
11:20:23 PM: info  - Generating static pages (38/76)
11:20:24 PM: info  - Generating static pages (57/76)
11:20:24 PM: info  - Generating static pages (76/76)
11:20:25 PM: info  - Finalizing page optimization...
11:20:25 PM: Page                                Size     First Load JS
11:20:25 PM: ┌ ○ / (904 ms)                      3.88 kB        70.5 kB
11:20:25 PM: ├   └ css/61278f179f48db7df8f1.css  765 B
11:20:25 PM: ├   /_app                           0 B            66.7 kB
11:20:25 PM: ├ ○ /404                            194 B          66.9 kB
11:20:25 PM: ├ ● /videos (2954 ms)               1.75 kB        68.4 kB
11:20:25 PM: └ ● /videos/[videoId] (12603 ms)    739 B          67.4 kB
11:20:25 PM:     ├ /videos/359 (1621 ms)
11:20:25 PM:     ├ /videos/79 (1521 ms)
11:20:25 PM:     ├ /videos/210 (1492 ms)
11:20:25 PM:     ├ /videos/266 (1210 ms)
11:20:25 PM:     ├ /videos/209 (1189 ms)
11:20:25 PM:     ├ /videos/265 (1090 ms)
11:20:25 PM:     ├ /videos/197 (312 ms)
11:20:25 PM:     └ [+65 more paths]
11:20:25 PM: + First Load JS shared by all       66.7 kB
11:20:25 PM:   ├ chunks/framework.895f06.js      42 kB
11:20:25 PM:   ├ chunks/main.62b8ca.js           23.3 kB
11:20:25 PM:   ├ chunks/pages/_app.a40023.js     555 B
11:20:25 PM:   ├ chunks/webpack.fb7614.js        770 B
11:20:25 PM:   └ css/120f2e2270820d49a21f.css    209 B
11:20:25 PM: λ  (Lambda)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
11:20:25 PM: ○  (Static)  automatically rendered as static HTML (uses no initial props)
11:20:25 PM: ●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
11:20:25 PM:    (ISR)     incremental static regeneration (uses revalidate in getStaticProps)
11:20:25 PM: ​
11:20:25 PM: (build.command completed in 30.5s)
11:20:25 PM: ​
11:20:25 PM: ────────────────────────────────────────────────────────────────
11:20:25 PM:   3. onBuild command from @netlify/plugin-nextjs                
11:20:25 PM: ────────────────────────────────────────────────────────────────
11:20:25 PM: ​
11:20:25 PM: Detected Next.js site. Copying files...
11:20:25 PM: ** Running Next on Netlify package **
11:20:25 PM: 🚀 Next on Netlify 🚀
11:20:25 PM: 🌍️ Copying public folder to /opt/build/repo/out
11:20:25 PM: 💼 Copying static NextJS assets to /opt/build/repo/out
11:20:25 PM: 💫 Setting up API endpoints as Netlify Functions in /opt/build/repo/.netlify/functions-internal
11:20:25 PM: 💫 Setting up pages with getInitialProps as Netlify Functions in /opt/build/repo/.netlify/functions-internal
11:20:25 PM: 💫 Setting up pages with getServerSideProps as Netlify Functions in /opt/build/repo/.netlify/functions-internal
11:20:25 PM: 🔥 Copying pre-rendered pages with getStaticProps and JSON data to /opt/build/repo/out
11:20:25 PM: 💫 Setting up pages with getStaticProps and fallback: true as Netlify Functions in /opt/build/repo/.netlify/functions-internal
11:20:25 PM: 💫 Setting up pages with getStaticProps and revalidation interval as Netlify Functions in /opt/build/repo/.netlify/functions-internal
11:20:25 PM: 🔥 Copying pre-rendered pages without props to /opt/build/repo/out
11:20:25 PM: Building 150 pages
11:20:25 PM: 🔀 Setting up redirects
11:20:25 PM: 🔀 Setting up headers
11:20:25 PM: ✅ Success! All done!
11:20:25 PM: ​
11:20:25 PM: (@netlify/plugin-nextjs onBuild completed in 330ms)
11:20:25 PM: ​
11:20:25 PM: ────────────────────────────────────────────────────────────────
11:20:25 PM:   4. Functions bundling                                         
11:20:25 PM: ────────────────────────────────────────────────────────────────
11:20:25 PM: ​
11:20:25 PM: Packaging Functions from .netlify/functions-internal directory:
11:20:25 PM:  - next_image/next_image.js
11:20:25 PM:  - next_videos/next_videos.js
11:20:25 PM:  - next_videos_videoId/next_videos_videoId.js
11:20:25 PM: ​
11:20:27 PM: ​
11:20:27 PM: ────────────────────────────────────────────────────────────────
11:20:27 PM:   Internal error during "Functions bundling"                    
11:20:27 PM: ────────────────────────────────────────────────────────────────
11:20:27 PM: ​
11:20:27 PM:   Error message
11:20:27 PM:   Error: readdirp: root argument is required. Usage: readdirp(root, options)
11:20:27 PM: ​
11:20:27 PM:   Error location
11:20:27 PM:   During Functions bundling
11:20:27 PM:       at readdirp (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/readdirp/index.js:262:11)
11:20:27 PM:       at /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/readdirp/index.js:276:5
11:20:27 PM:       at new Promise (<anonymous>)
11:20:27 PM:       at Function.readdirpPromise [as promise] (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/readdirp/index.js:274:10)
11:20:27 PM:       at hasFunctionRootFile (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:119:32)
11:20:27 PM:       at lacksNodeModules (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:111:12)
11:20:27 PM:       at getModuleNotFoundMessage (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:50:43)
11:20:27 PM:       at getModuleNotFoundErrorObject (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:41:25)
11:20:27 PM:       at getModuleNotFoundErrorFromZISI (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:91:10)
11:20:27 PM:       at getModuleNotFoundError (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:27:31)
11:20:27 PM: ​
11:20:27 PM:   Resolved config
11:20:27 PM:   build:
11:20:27 PM:     command: npm run build
11:20:27 PM:     commandOrigin: config
11:20:27 PM:     environment:
11:20:27 PM:       - CMS_DB_DB
11:20:27 PM:       - CMS_DB_HOST
11:20:27 PM:       - CMS_DB_PASS
11:20:27 PM:       - CMS_DB_PORT
11:20:27 PM:       - CMS_DB_USER
11:20:27 PM:     publish: /opt/build/repo/out
11:20:27 PM:     publishOrigin: config
11:20:27 PM:   headers:
11:20:35 PM:     - for: /_next/static/chunks/*      values:        cache-control: public, max-age=31536000, immutable  plugins:    - inputs: {}      origin: ui      package: '@netlify/plugin-nextjs'  redirects:    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /_next/data/dpTbnK-UeX08oHW4eWGg6/videos.json      status: 200      to: /.netlify/functions/next_videos    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /_next/data/dpTbnK-UeX08oHW4eWGg6/videos/10248.json      status: 200      to: /.netlify/functions/next_videos_videoId    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /_next/data/dpTbnK-UeX08oHW4eWGg6/videos/127.json      status: 200      to: /.netlify/functions/next_videos_videoId    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /_next/data/dpTbnK-UeX08oHW4eWGg6/videos/143.json      status: 200      to: /.netlify/functions/next_videos_videoId    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /_next/data/dpTbnK-UeX08oHW4eWGg6/videos/153.json      status: 200      to: /.netlify/functions/next_videos_videoId    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /_next/data/dpTbnK-UeX08oHW4eWGg6/videos/16050.json      status: 200      to: /.netlify/functions/next_videos_videoId    - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /_next/data/dpTbnK-UeX08oHW4eWGg6/videos/1635.json      status: 200      to: /.netlify/functions/next_videos_videoId    [...]                                                                                               - conditions:        Cookie: __prerender_bypass,__next_preview_data      force: true      from: /videos/9619      status: 200      to: /.netlify/functions/next_videos_videoId    - force: true      from: /_next/image*      query:        q: ':quality'        url: ':url'        w: ':width'      status: 301      to: /nextimg/:url/:width/:quality    - from: /nextimg/*      status: 200      to: /.netlify/functions/next_imageCaching artifacts
11:20:35 PM: Started saving node modules
11:20:35 PM: Finished saving node modules
11:20:35 PM: Started saving build plugins
11:20:35 PM: Finished saving build plugins
11:20:35 PM: Started saving yarn cache
11:20:38 PM: Finished saving yarn cache
11:20:38 PM: Started saving pip cache
11:20:38 PM: Finished saving pip cache
11:20:38 PM: Started saving emacs cask dependencies
11:20:38 PM: Finished saving emacs cask dependencies
11:20:38 PM: Started saving maven dependencies
11:20:38 PM: Finished saving maven dependencies
11:20:38 PM: Started saving boot dependencies
11:20:38 PM: Finished saving boot dependencies
11:20:38 PM: Started saving rust rustup cache
11:20:38 PM: Finished saving rust rustup cache
11:20:38 PM: Started saving go dependencies
11:20:38 PM: Finished saving go dependencies
11:20:40 PM: Build failed due to an internal system error: Build script returned non-zero exit code: 4
11:20:40 PM: Creating deploy upload records
11:20:40 PM: Failing build: Failed to build site
11:20:40 PM: Failed during stage 'building site': Build script returned non-zero exit code: 4
11:20:40 PM: Finished processing build request in 1m28.943905867s

I ommitted some repetitive parts of the log as I was exceeding the post characters limit

Have you both tried this: