Nextjs: readdirp: root argument is required

Here are the full logs:

9:11:36 PM: Build ready to start
9:11:38 PM: build-image version: c6001ed68662a13e5deb24abec2b46058c58248a
9:11:38 PM: build-image tag: v3.9.0
9:11:38 PM: buildbot version: f4173981fcd5d3dcb6b43522b0a054a70c5b6457
9:11:38 PM: Fetching cached dependencies
9:11:38 PM: Starting to download cache of 558.2MB
9:11:41 PM: Finished downloading cache in 3.316097617s
9:11:41 PM: Starting to extract cache
9:12:02 PM: Finished extracting cache in 20.451858608s
9:12:02 PM: Finished fetching cache in 23.923107068s
9:12:02 PM: Starting to prepare the repo for build
9:12:04 PM: Preparing Git Reference refs/heads/deploy/prod
9:12:05 PM: Parsing package.json dependencies
9:12:06 PM: Starting build script
9:12:06 PM: Installing dependencies
9:12:06 PM: Python version set to 2.7
9:12:07 PM: Started restoring cached node version
9:12:09 PM: Finished restoring cached node version
9:12:10 PM: v12.18.0 is already installed.
9:12:11 PM: Now using node v12.18.0 (npm v6.14.4)
9:12:11 PM: Started restoring cached build plugins
9:12:11 PM: Finished restoring cached build plugins
9:12:11 PM: Attempting ruby version 2.7.1, read from environment
9:12:11 PM: Started restoring cached ruby version
9:12:11 PM: Finished restoring cached ruby version
9:12:14 PM: Using ruby version 2.7.1
9:12:14 PM: Using PHP version 5.6
9:12:14 PM: Started restoring cached yarn cache
9:12:22 PM: Finished restoring cached yarn cache
9:12:22 PM: Yarn workspaces detected
9:12:22 PM: Started restoring workspace components/components node modules
9:12:22 PM: Finished restoring workspace components/components node modules
9:12:22 PM: Started restoring workspace apps/leander-tile node modules
9:12:22 PM: Finished restoring workspace apps/leander-tile node modules
9:12:22 PM: Started restoring workspace apps/urielavalos node modules
9:12:22 PM: Finished restoring workspace apps/urielavalos node modules
9:12:22 PM: Started restoring workspace netlify-utils/plugins/monorepo-build-check node modules
9:12:22 PM: Finished restoring workspace netlify-utils/plugins/monorepo-build-check node modules
9:12:22 PM: Started restoring workspace root node modules
9:12:22 PM: Finished restoring workspace root node modules
9:12:23 PM: Installing NPM modules using Yarn version 1.22.4
9:12:23 PM: yarn install v1.22.4
9:12:23 PM: [1/4] Resolving packages...
9:12:24 PM: [2/4] Fetching packages...
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-bloom@3.2.0" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-bloom@3.2.0" has unmet peer dependency "@pixi/filter-alpha@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-bloom@3.2.0" has unmet peer dependency "@pixi/filter-blur@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-bloom@3.2.0" has unmet peer dependency "@pixi/math@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-bloom@3.2.0" has unmet peer dependency "@pixi/settings@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-bulge-pinch@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-color-map@3.1.1" has unmet peer dependency "@pixi/constants@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-color-map@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-color-overlay@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-color-overlay@3.1.1" has unmet peer dependency "@pixi/utils@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-color-replace@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-color-replace@3.1.1" has unmet peer dependency "@pixi/utils@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-convolution@3.2.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-cross-hatch@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-crt@3.2.0" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-dot@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-drop-shadow@3.2.0" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-drop-shadow@3.2.0" has unmet peer dependency "@pixi/math@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-drop-shadow@3.2.0" has unmet peer dependency "@pixi/settings@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-drop-shadow@3.2.0" has unmet peer dependency "@pixi/utils@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-emboss@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-glitch@3.1.1" has unmet peer dependency "@pixi/constants@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-glitch@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-glitch@3.1.1" has unmet peer dependency "@pixi/math@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-glow@3.2.0" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-glow@3.2.0" has unmet peer dependency "@pixi/utils@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-godray@3.2.0" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-godray@3.2.0" has unmet peer dependency "@pixi/math@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-kawase-blur@3.2.0" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-kawase-blur@3.2.0" has unmet peer dependency "@pixi/math@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-motion-blur@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-motion-blur@3.1.1" has unmet peer dependency "@pixi/math@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-multi-color-replace@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-multi-color-replace@3.1.1" has unmet peer dependency "@pixi/utils@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-old-film@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-outline@3.2.0" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-outline@3.2.0" has unmet peer dependency "@pixi/utils@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-pixelate@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-radial-blur@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-reflection@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-rgb-split@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-shockwave@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-simple-lightmap@3.1.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-simple-lightmap@3.1.1" has unmet peer dependency "@pixi/utils@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-tilt-shift@3.2.0" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-tilt-shift@3.2.0" has unmet peer dependency "@pixi/math@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-twist@3.2.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-twist@3.2.1" has unmet peer dependency "@pixi/math@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/urielavalos > pixi-filters > @pixi/filter-zoom-blur@3.2.1" has unmet peer dependency "@pixi/core@^5.0.0".
9:12:35 PM: warning "workspace-aggregator-a90d8d62-9391-45ae-a28c-b2aeb6a50ceb > @robotandkid/components > next > styled-jsx > @babel/plugin-syntax-jsx@7.14.5" has unmet peer dependency "@babel/core@^7.0.0-0".
9:12:35 PM: warning Workspaces can only be enabled in private projects.
9:12:35 PM: warning Workspaces can only be enabled in private projects.
9:12:35 PM: warning Workspaces can only be enabled in private projects.
9:12:35 PM: warning Workspaces can only be enabled in private projects.
9:12:35 PM: warning Workspaces can only be enabled in private projects.
9:12:35 PM: warning Workspaces can only be enabled in private projects.
9:12:44 PM: [4/4] Building fresh packages...
9:12:45 PM: $ husky install
9:12:45 PM: husky - Git hooks installed
9:12:45 PM: Done in 22.00s.
9:12:45 PM: NPM modules installed using Yarn
9:12:45 PM: Started restoring cached go cache
9:12:45 PM: Finished restoring cached go cache
9:12:45 PM: go version go1.14.4 linux/amd64
9:12:45 PM: go version go1.14.4 linux/amd64
9:12:45 PM: Installing missing commands
9:12:45 PM: Verify run directory
9:12:47 PM: ​
9:12:47 PM: ────────────────────────────────────────────────────────────────
9:12:47 PM:   Netlify Build                                                 
9:12:47 PM: ────────────────────────────────────────────────────────────────
9:12:47 PM: ​
9:12:47 PM: ❯ Version
9:12:47 PM:   @netlify/build 18.13.1
9:12:47 PM: ​
9:12:47 PM: ❯ Flags
9:12:47 PM:   baseRelDir: true
9:12:47 PM:   buildId: 6153cb58d832dc0007e1c681
9:12:47 PM:   deployId: 6153cb58d832dc0007e1c683
9:12:47 PM: ​
9:12:47 PM: ❯ Current directory
9:12:47 PM:   /opt/build/repo
9:12:47 PM: ​
9:12:47 PM: ❯ Config file
9:12:47 PM:   /opt/build/repo/netlify.toml
9:12:47 PM: ​
9:12:47 PM: ❯ Context
9:12:47 PM:   production
9:12:47 PM: ​
9:12:47 PM: ❯ Loading plugins
9:12:47 PM:    - @netlify/plugin-nextjs@3.9.0 from Netlify app
9:12:47 PM:    - /netlify-utils/plugins/monorepo-build-check@0.1.0 from netlify.toml
9:12:48 PM: ​
9:12:48 PM: ────────────────────────────────────────────────────────────────
9:12:48 PM:   1. onPreBuild command from @netlify/plugin-nextjs             
9:12:48 PM: ────────────────────────────────────────────────────────────────
9:12:48 PM: ​
9:12:48 PM: Using Next.js 11.1.2
9:12:48 PM: Warning: support for Next.js >=11.1.0 is experimental
9:12:48 PM: info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
9:12:49 PM: Next.js cache restored.
9:12:49 PM: ​
9:12:49 PM: (@netlify/plugin-nextjs onPreBuild completed in 1s)
9:12:49 PM: ​
9:12:49 PM: ──────────────────────────────────────────────────────────────────────────
9:12:49 PM:   2. onPreBuild command from /netlify-utils/plugins/monorepo-build-check  
9:12:49 PM: ──────────────────────────────────────────────────────────────────────────
9:12:49 PM: ​
9:12:49 PM: yarn run v1.22.4
9:12:49 PM: $ /opt/build/repo/node_modules/.bin/lerna ls --all --graph
9:12:49 PM: lerna notice cli v4.0.0
9:12:49 PM: lerna info versioning independent
9:12:49 PM: lerna info ci enabled
9:12:49 PM: {
9:12:49 PM:   "@robotandkid/leander-tile": [
9:12:49 PM:     "@babel/core",
9:12:49 PM:     "@mdx-js/loader",
9:12:49 PM:     "@next/mdx",
9:12:49 PM:     "@robotandkid/components",
9:12:49 PM:     "@testing-library/react",
9:12:49 PM:     "babel-plugin-styled-components",
9:12:49 PM:     "framer-motion",
9:12:49 PM:     "gray-matter",
9:12:49 PM:     "html-webpack-plugin",
9:12:49 PM:     "i18next",
9:12:49 PM:     "next",
9:12:49 PM:     "react",
9:12:49 PM:     "react-cosmos",
9:12:49 PM:     "react-dom",
9:12:49 PM:     "react-i18next",
9:12:49 PM:     "styled-components"
9:12:49 PM:   ],
9:12:49 PM:   "@robotandkid/urielavalos": [
9:12:49 PM:     "@mapbox/rehype-prism",
9:12:49 PM:     "@mdx-js/loader",
9:12:49 PM:     "@mdx-js/react",
9:12:49 PM:     "@next/mdx",
9:12:49 PM:     "@robotandkid/components",
9:12:49 PM:     "@testing-library/cypress",
9:12:49 PM:     "@testing-library/react",
9:12:49 PM:     "@types/jscodeshift",
9:12:49 PM:     "@types/matter-js",
9:12:49 PM:     "@types/mdx-js__react",
9:12:49 PM:     "awesome-retro-video-game-cutscenes",
9:12:49 PM:     "cypress",
9:12:49 PM:     "eslint-plugin-cypress",
9:12:49 PM:     "fp-ts",
9:12:49 PM:     "framer-motion",
9:12:49 PM:     "gray-matter",
9:12:49 PM:     "html-webpack-plugin",
9:12:49 PM:     "http-server",
9:12:49 PM:     "io-ts",
9:12:49 PM:     "jscodeshift",
9:12:49 PM:     "matter-js",
9:12:49 PM:     "next",
9:12:49 PM:     "next-mdx-remote",
9:12:49 PM:     "phosphor-react",
9:12:49 PM:     "pixi-filters",
9:12:49 PM:     "pixi-sound",
9:12:49 PM:     "pixi.js",
9:12:49 PM:     "react",
9:12:49 PM:     "react-cosmos",
9:12:49 PM:     "react-dom",
9:12:49 PM:     "start-server-and-test",
9:12:49 PM:     "styled-components"
9:12:49 PM:   ],
9:12:49 PM:   "@robotandkid/components": [
9:12:49 PM:     "@rollup/plugin-node-resolve",
9:12:49 PM:     "@rollup/plugin-typescript",
9:12:49 PM:     "@testing-library/react",
9:12:49 PM:     "acorn-jsx",
9:12:49 PM:     "framer-motion",
9:12:49 PM:     "html-webpack-plugin",
9:12:49 PM:     "next",
9:12:49 PM:     "phosphor-react",
9:12:49 PM:     "react",
9:12:49 PM:     "react-cosmos",
9:12:49 PM:     "react-dom",
9:12:49 PM:     "rollup",
9:12:49 PM:     "styled-components",
9:12:49 PM:     "tslib"
9:12:49 PM:   ],
9:12:49 PM:   "@robotandkid/monorepo-build-check": [
9:12:49 PM:     "jest",
9:12:49 PM:     "lerna"
9:12:49 PM:   ]
9:12:49 PM: }
9:12:49 PM: lerna success found 4 packages
9:12:49 PM: Done in 0.43s.
9:12:50 PM: yarn run v1.22.4
9:12:50 PM: $ /opt/build/repo/node_modules/.bin/lerna ls --all --json --since 23c3263d5b3fa1c5a72d30170434d76cce2fa2a6
9:12:50 PM: lerna notice cli v4.0.0
9:12:50 PM: lerna info versioning independent
9:12:50 PM: lerna info ci enabled
9:12:50 PM: lerna notice filter changed since "23c3263d5b3fa1c5a72d30170434d76cce2fa2a6"
9:12:50 PM: lerna info Looking for changed packages since 23c3263d5b3fa1c5a72d30170434d76cce2fa2a6
9:12:50 PM: lerna info ignoring diff in paths matching [ '**/*.md', '**/.next/*', '*.md', '/.next' ]
9:12:50 PM: [
9:12:50 PM:   {
9:12:50 PM:     "name": "@robotandkid/leander-tile",
9:12:50 PM:     "version": "0.22.4",
9:12:50 PM:     "private": true,
9:12:50 PM:     "location": "/opt/build/repo/apps/leander-tile"
9:12:50 PM:   },
9:12:50 PM:   {
9:12:50 PM:     "name": "@robotandkid/urielavalos",
9:12:50 PM:     "version": "0.30.3",
9:12:50 PM:     "private": true,
9:12:50 PM:     "location": "/opt/build/repo/apps/urielavalos"
9:12:50 PM:   },
9:12:50 PM:   {
9:12:50 PM:     "name": "@robotandkid/components",
9:12:50 PM:     "version": "0.16.4",
9:12:50 PM:     "private": true,
9:12:50 PM:     "location": "/opt/build/repo/components/components"
9:12:50 PM:   }
9:12:50 PM: ]
9:12:50 PM: lerna success found 3 packages
9:12:50 PM: Done in 0.56s.
9:12:50 PM: ​
9:12:50 PM: (/netlify-utils/plugins/monorepo-build-check onPreBuild completed in 1.4s)
9:12:50 PM: ​
9:12:50 PM: ────────────────────────────────────────────────────────────────
9:12:50 PM:   3. Build command from Netlify app                             
9:12:50 PM: ────────────────────────────────────────────────────────────────
9:12:50 PM: ​
9:12:50 PM: $ cd apps/leander-tile && yarn next build
9:12:50 PM: yarn run v1.22.4
9:12:50 PM: $ /opt/build/repo/node_modules/.bin/next build
9:12:51 PM: info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
9:12:52 PM: info  - Checking validity of types...
9:12:52 PM: warn  - Minimum recommended TypeScript version is v4.3.2, older versions can potentially be incompatible with Next.js. Detected: 4.2.4
9:13:02 PM: warn  - No ESLint configuration detected. Run next lint to begin setup
9:13:02 PM: info  - Creating an optimized production build...
9:13:32 PM: (node:1707) [DEP_WEBPACK_CHUNK_HAS_ENTRY_MODULE] DeprecationWarning: Chunk.hasEntryModule: Use new ChunkGraph API
9:13:35 PM: warn  - Compiled with warnings
9:13:35 PM: ../../node_modules/next/dist/server/load-components.js
9:13:35 PM: Critical dependency: the request of a dependency is an expression
9:13:35 PM: ../../node_modules/next/dist/server/load-components.js
9:13:35 PM: Critical dependency: the request of a dependency is an expression
9:13:35 PM: ../../node_modules/next/dist/server/load-components.js
9:13:35 PM: Critical dependency: the request of a dependency is an expression
9:13:35 PM: ../../node_modules/next/dist/server/require.js
9:13:35 PM: Critical dependency: the request of a dependency is an expression
9:13:35 PM: ../../node_modules/next/dist/server/require.js
9:13:35 PM: Critical dependency: the request of a dependency is an expression
9:13:35 PM: ../../node_modules/next/dist/server/require.js
9:13:35 PM: Critical dependency: the request of a dependency is an expression
9:13:35 PM: info  - Collecting page data...
9:13:38 PM: info  - Generating static pages (0/11)
9:13:42 PM: info  - Generating static pages (2/11)
9:13:42 PM: info  - Generating static pages (5/11)
9:13:42 PM: info  - Generating static pages (8/11)
9:13:42 PM: info  - Generating static pages (11/11)
9:13:42 PM: info  - Finalizing page optimization...
9:13:42 PM: Page                             Size     First Load JS
9:13:42 PM: ┌ ● /                            3.38 kB         189 kB
9:13:42 PM: ├   /_app                        0 B             186 kB
9:13:42 PM: ├ ○ /404                         193 B           186 kB
9:13:42 PM: └ ○ /thanks (2988 ms)            670 B           186 kB
9:13:42 PM: + First Load JS shared by all    186 kB
9:13:42 PM:   ├ chunks/framework.ea4a1f.js   46.6 kB
9:13:42 PM:   ├ chunks/main.64ed94.js        24.5 kB
9:13:42 PM:   ├ chunks/pages/_app.bcab2a.js  114 kB
9:13:42 PM:   └ chunks/webpack.fb7614.js     770 B
9:13:42 PM: λ  (Lambda)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
9:13:42 PM: ○  (Static)  automatically rendered as static HTML (uses no initial props)
9:13:42 PM: ●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
9:13:42 PM:    (ISR)     incremental static regeneration (uses revalidate in getStaticProps)
9:13:42 PM: Done in 51.99s.
9:13:42 PM: ​
9:13:42 PM: (build.command completed in 52.1s)
9:13:42 PM: ​
9:13:42 PM: ────────────────────────────────────────────────────────────────
9:13:42 PM:   4. onBuild command from @netlify/plugin-nextjs                
9:13:42 PM: ────────────────────────────────────────────────────────────────
9:13:42 PM: ​
9:13:42 PM: Detected Next.js site. Copying files...
9:13:42 PM: ** Running Next on Netlify package **
9:13:42 PM: 🚀 Next on Netlify 🚀
9:13:42 PM: 🌍️ Copying public folder to /opt/build/repo/apps/leander-tile/out
9:13:42 PM: 💼 Copying static NextJS assets to /opt/build/repo/apps/leander-tile/out
9:13:42 PM: 💫 Setting up API endpoints as Netlify Functions in /opt/build/repo/.netlify/functions-internal
9:13:42 PM: 💫 Setting up pages with getInitialProps as Netlify Functions in /opt/build/repo/.netlify/functions-internal
9:13:42 PM: 💫 Setting up pages with getServerSideProps as Netlify Functions in /opt/build/repo/.netlify/functions-internal
9:13:42 PM: 🔥 Copying pre-rendered pages with getStaticProps and JSON data to /opt/build/repo/apps/leander-tile/out
9:13:42 PM: 💫 Setting up pages with getStaticProps and fallback: true as Netlify Functions in /opt/build/repo/.netlify/functions-internal
9:13:42 PM: 💫 Setting up pages with getStaticProps and revalidation interval as Netlify Functions in /opt/build/repo/.netlify/functions-internal
9:13:42 PM: 🔥 Copying pre-rendered pages without props to /opt/build/repo/apps/leander-tile/out
9:13:42 PM: Building 11 pages
9:13:42 PM: 🔀 Setting up redirects
9:13:42 PM: 🔀 Setting up headers
9:13:42 PM: ✅ Success! All done!
9:13:43 PM: ​
9:13:43 PM: (@netlify/plugin-nextjs onBuild completed in 99ms)
9:13:43 PM: ​
9:13:43 PM: ────────────────────────────────────────────────────────────────
9:13:43 PM:   5. Functions bundling                                         
9:13:43 PM: ────────────────────────────────────────────────────────────────
9:13:43 PM: ​
9:13:43 PM: Packaging Functions from .netlify/functions-internal directory:
9:13:43 PM:  - next_image/next_image.js
9:13:43 PM:  - next_index/next_index.js
9:13:43 PM: ​
9:13:44 PM: ​
9:13:44 PM: ────────────────────────────────────────────────────────────────
9:13:44 PM:   Internal error during "Functions bundling"                    
9:13:44 PM: ────────────────────────────────────────────────────────────────
9:13:44 PM: ​
9:13:44 PM:   Error message
9:13:44 PM:   Error: readdirp: root argument is required. Usage: readdirp(root, options)
9:13:44 PM: ​
9:13:44 PM:   Error location
9:13:44 PM:   During Functions bundling
9:13:44 PM:       at readdirp (/opt/buildhome/.netlify-build-nvm/versions/node/v12.22.6/lib/node_modules/@netlify/build/node_modules/readdirp/index.js:262:11)
9:13:44 PM:       at /opt/buildhome/.netlify-build-nvm/versions/node/v12.22.6/lib/node_modules/@netlify/build/node_modules/readdirp/index.js:276:5
9:13:44 PM:       at new Promise (<anonymous>)
9:13:44 PM:       at Function.readdirpPromise [as promise] (/opt/buildhome/.netlify-build-nvm/versions/node/v12.22.6/lib/node_modules/@netlify/build/node_modules/readdirp/index.js:274:10)
9:13:44 PM:       at hasFunctionRootFile (/opt/buildhome/.netlify-build-nvm/versions/node/v12.22.6/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:119:32)
9:13:44 PM:       at lacksNodeModules (/opt/buildhome/.netlify-build-nvm/versions/node/v12.22.6/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:111:12)
9:13:44 PM:       at getModuleNotFoundMessage (/opt/buildhome/.netlify-build-nvm/versions/node/v12.22.6/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:50:43)
9:13:44 PM:       at getModuleNotFoundErrorObject (/opt/buildhome/.netlify-build-nvm/versions/node/v12.22.6/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:41:25)
9:13:44 PM:       at getModuleNotFoundErrorFromZISI (/opt/buildhome/.netlify-build-nvm/versions/node/v12.22.6/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:91:10)
9:13:44 PM:       at getModuleNotFoundError (/opt/buildhome/.netlify-build-nvm/versions/node/v12.22.6/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:27:31)
9:13:44 PM: ​
9:13:44 PM:   Resolved config
9:13:44 PM:   build:
9:13:44 PM:     command: cd apps/leander-tile && yarn next build
9:13:44 PM:     commandOrigin: ui
9:13:44 PM:     publish: /opt/build/repo/apps/leander-tile/out
9:13:44 PM:     publishOrigin: ui
9:13:44 PM:   headers:
9:13:49 PM:     - for: /_next/static/chunks/*
      values:
        cache-control: public, max-age=31536000, immutable
  plugins:
    - inputs: {}
      origin: ui
      package: '@netlify/plugin-nextjs'
    - inputs: {}
      origin: config
      package: /netlify-utils/plugins/monorepo-build-check
  redirects:
    - conditions:
        Cookie: __prerender_bypass,__next_preview_data
      force: true
      from: /
      status: 200
      to: /.netlify/functions/next_index
    - from: /
      status: 200
      to: /en
    - from: /404
      status: 200
      to: /en/404.html
    - from: /500
      status: 200
      to: /en/500.html
    - conditions:
        Cookie: __prerender_bypass,__next_preview_data
      force: true
      from: /_next/data/S6LFJ6jIVGb44XFKrt43a/en.json
      status: 200
      to: /.netlify/functions/next_index
    - conditions:
        Cookie: __prerender_bypass,__next_preview_data
      force: true
      from: /_next/data/S6LFJ6jIVGb44XFKrt43a/es.json
      status: 200
      to: /.netlify/functions/next_index
    - conditions:
        Cookie: __prerender_bypass,__next_preview_data
      force: true
      from: /en
      status: 200
      to: /.netlify/functions/next_index
    - conditions:
        Cookie: __prerender_bypass,__next_preview_data
      force: true
      from: /es
      status: 200
      to: /.netlify/functions/next_index
    - from: /thanks
      status: 200
      to: /en/thanks.html
    - 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_image
Caching artifacts
9:13:49 PM: Started saving workspace components/components node modules
9:13:49 PM: Finished saving workspace components/components node modules
9:13:49 PM: Started saving workspace apps/leander-tile node modules
9:13:49 PM: Finished saving workspace apps/leander-tile node modules
9:13:49 PM: Started saving workspace apps/urielavalos node modules
9:13:49 PM: Finished saving workspace apps/urielavalos node modules
9:13:49 PM: Started saving workspace netlify-utils/plugins/monorepo-build-check node modules
9:13:49 PM: Finished saving workspace netlify-utils/plugins/monorepo-build-check node modules
9:13:49 PM: Started saving workspace root node modules
9:13:49 PM: Finished saving workspace root node modules
9:13:49 PM: Started saving build plugins
9:13:49 PM: Finished saving build plugins
9:13:49 PM: Started saving yarn cache
9:14:00 PM: Finished saving yarn cache
9:14:00 PM: Started saving pip cache
9:14:00 PM: Finished saving pip cache
9:14:00 PM: Started saving emacs cask dependencies
9:14:00 PM: Finished saving emacs cask dependencies
9:14:00 PM: Started saving maven dependencies
9:14:00 PM: Finished saving maven dependencies
9:14:00 PM: Started saving boot dependencies
9:14:00 PM: Finished saving boot dependencies
9:14:00 PM: Started saving rust rustup cache
9:14:00 PM: Finished saving rust rustup cache
9:14:00 PM: Started saving go dependencies
9:14:00 PM: Finished saving go dependencies
9:14:00 PM: Build failed due to an internal system error: Build script returned non-zero exit code: 4
9:14:00 PM: Creating deploy upload records
9:14:00 PM: Failing build: Failed to build site
9:14:00 PM: Failed during stage 'building site': Build script returned non-zero exit code: 4
9:14:00 PM: Finished processing build request in 2m22.359551412s```

Hi @adancingteddybear,

This might help:

No that’s the solution that I referenced and it doesn’t work.
More info

  • I put a netlify.toml with node_bundler = "esbuild" as suggested
  • Build now says that it’s failing because error: Could not resolve "critters"
  • So I added this to the config.externals as described in the post you recommended.
  • However, it is still failing with the same error message. Could not resolve "Critters"

Here is my next.config

const path = require("path");

const extension = /\.mdx?$/;

const withMDX = require("@next/mdx")({
  extension,
});

module.exports = withMDX({
  async headers() {
    return [
      {
        source: "/fonts/mrpixel.otf",
        headers: [
          {
            key: "Cache-Control",
            value: "public, immutable, max-age=31536000",
          },
        ],
      },
    ];
  },
  pageExtensions: ["js", "jsx", "ts", "tsx", "mdx"],
  webpack(config) {
    const mdxRule = config.module.rules.find(
      (rule) => `${rule.test}` === `${extension}`
    );
    if (mdxRule) {
      mdxRule.use.push(path.join(__dirname, "./mdx-fm-loader"));
    }

    // netlify bug:
    // https://answers.netlify.com/t/next-js-internal-error-during-functions-bundling-on-build/43647/7
    config.externals = config.externals.concat([
      "mssql",
      "mysql2",
      "oracle",
      "oracledb",
      "postgres",
      "redshift",
      "sqlite3",
      "pg",
      "pg-query-stream",
      "tedious",
      "critters",
      { knex: "commonjs knex" },
    ]);

    return config;
  },
  images: {
    loader: "imgix",
    path: "",
  },
  i18n: {
    defaultLocale: "en",
    locales: ["en", "es"],
  },
  target: "serverless",
});

Here is the new error message:

9:39:55 PM: Packaging Functions from .netlify/functions-internal directory:
9:39:55 PM:  - next_image/next_image.js
9:39:55 PM:  - next_index/next_index.js
9:39:55 PM: ​
9:39:55 PM:  > .netlify/functions-internal/next_index/nextPage/pages/index.js:2314:25: error: Could not resolve "critters" (mark it as external to exclude it from the bundle, or surround it with try/catch to handle the failure at run-time)
9:39:55 PM:     2314 │ module.exports = require("critters");

@hrishikesh See my response ^^^^

@hrishikesh Updates:

  • I was able to get it to work by adding critters as a DEV dependencies.
  • So I believe the correct resolution steps might be: (a) add node_bundler = "esbuild" to the netlify.toml — this allows you to find which module is missing. (b) add the missing module as external module to the next.config.js webpack config (c) add the dependency as a DEV dependency (in package.json).

Note: As per the official webpack docs, I believe the post linked to above is incorrect. config.externals is an object, not an array in the latest version of webpack. So this is my configuration:

webpack(config) {
    const mdxRule = config.module.rules.find(
      (rule) => `${rule.test}` === `${extension}`
    );
    if (mdxRule) {
      mdxRule.use.push(path.join(__dirname, "./mdx-fm-loader"));
    }

    // netlify bug:
    // https://answers.netlify.com/t/next-js-internal-error-during-functions-bundling-on-build/43647/7
    Object.assign(
      config.externals,
      [
        "critters",
      ].reduce(
        (externals, name) => ({ ...externals, [name]: `commonjs ${name}` }),
        {}
      )
    );

    return config;
  },

Yes, marking as externals would help with the bundling, but the module is still required to be installed. That’s what you’ve done by adding the package to devDependencies, though I’d advise to keep it in dependencies.