netlify / next-runtime

The Next.js Runtime allows Next.js to run on Netlify with zero configuration
https://www.npmjs.com/package/@netlify/plugin-nextjs
639 stars 85 forks source link

Build Error - Plugin "@netlify/plugin-nextjs" internal error #2024

Closed joeluna17 closed 1 year ago

joeluna17 commented 1 year ago

Pushed new code and during deployment I'm receiving and error from the plugin. This worked last for me on 3/18/2023. I've tried deselecting the plugin from runtime, and then reselecting then recaching and redeploying with no luck. Below is the error output.

4:02:29 PM: build-image version: 6c82004ef0368b3a0232c6837cead23188bb347e (focal) 4:02:29 PM: buildbot version: 0dfbdb6e6e614fd26450cfc6bacb47c4c6fd9626 4:02:29 PM: Building without cache 4:02:29 PM: Starting to prepare the repo for build 4:02:29 PM: No cached dependencies found. Cloning fresh repo 4:02:29 PM: git clone --filter=blob:none git@gitlab.com:joelunaGetCheckApp/check-forms-app 4:02:30 PM: Preparing Git Reference refs/heads/main 4:02:32 PM: Parsing package.json dependencies 4:02:33 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: 'apps' versus 'apps/' in the Netlify UI 4:02:33 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'dist/apps/check-payments-marketing/.next' versus '../dist/apps/check-payments-marketing/.next' in the Netlify UI 4:02:33 PM: Starting to install dependencies 4:02:33 PM: Python version set to 3.8 4:02:33 PM: Started restoring cached go cache 4:02:33 PM: Finished restoring cached go cache 4:02:33 PM: Installing Go version 1.19.5 (requested 1.19.5) 4:02:38 PM: go version go1.19.5 linux/amd64 4:02:38 PM: Using PHP version 8.0 4:02:38 PM: v16.20.0 is already installed. 4:02:38 PM: Now using node v16.20.0 (npm v8.19.4) 4:02:39 PM: Enabling Node.js Corepack 4:02:39 PM: Started restoring cached build plugins 4:02:39 PM: Finished restoring cached build plugins 4:02:39 PM: Attempting Ruby version 2.7.2, read from environment 4:02:39 PM: Using Ruby version 2.7.2 4:02:40 PM: Install dependencies script success 4:02:40 PM: Starting build script 4:02:40 PM: Using stage install dependencies 4:02:41 PM: Detected 2 framework(s) 4:02:41 PM: "next-nx" at version "unknown" 4:02:41 PM: "create-react-app" at version "unknown" 4:02:41 PM: Section completed: initializing 4:02:42 PM: ​ 4:02:42 PM: Netlify Build
4:02:42 PM: ──────────────────────────────────────────────────────────────── 4:02:42 PM: ​ 4:02:42 PM: ❯ Version 4:02:42 PM: @netlify/build 29.9.0 4:02:42 PM: ​ 4:02:42 PM: ❯ Flags 4:02:42 PM: baseRelDir: true 4:02:42 PM: buildId: 6429ed5ef88833550b63cea1 4:02:42 PM: deployId: 6429ed5ef88833550b63cea3 4:02:42 PM: ​ 4:02:42 PM: ❯ Current directory 4:02:42 PM: /opt/build/repo/apps 4:02:42 PM: ​ 4:02:42 PM: ❯ Config file 4:02:42 PM: No config file was defined: using default values. 4:02:42 PM: ​ 4:02:42 PM: ❯ Context 4:02:42 PM: production 4:02:42 PM: ​ 4:02:42 PM: ❯ Installing plugins 4:02:42 PM: - @netlify/plugin-nextjs@4.33.0 4:02:53 PM: ​ 4:02:53 PM: ❯ Using Next.js Runtime - v4.33.0 4:02:54 PM: ​ 4:02:54 PM: Plugin "@netlify/plugin-nextjs" internal error
4:02:54 PM: ──────────────────────────────────────────────────────────────── 4:02:54 PM: ​ 4:02:54 PM: Error message 4:02:54 PM: Could not import plugin: 4:02:54 PM: Error: Could not find Next.js server 4:02:54 PM: ​ 4:02:54 PM: Plugin details 4:02:54 PM: Package: @netlify/plugin-nextjs 4:02:54 PM: Version: 4.33.0 4:02:54 PM: Repository: git+https://github.com/netlify/next-runtime.git 4:02:54 PM: npm link: https://www.npmjs.com/package/@netlify/plugin-nextjs 4:02:54 PM: Report issues: https://github.com/netlify/next-runtime/issues 4:02:54 PM: ​ 4:02:54 PM: Error location 4:02:54 PM: While loading "@netlify/plugin-nextjs" from Netlify app 4:02:54 PM: at getNextServer (/opt/build/repo/apps/.netlify/plugins/node_modules/@netlify/plugin-nextjs/lib/templates/handlerUtils.js:169:19) 4:02:54 PM: at Object. (/opt/build/repo/apps/.netlify/plugins/node_modules/@netlify/plugin-nextjs/lib/templates/server.js:5:53) 4:02:54 PM: at Module._compile (node:internal/modules/cjs/loader:1196:14) 4:02:54 PM: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10) 4:02:54 PM: at Module.load (node:internal/modules/cjs/loader:1074:32) 4:02:54 PM: at Function.Module._load (node:internal/modules/cjs/loader:909:12) 4:02:54 PM: at Module.require (node:internal/modules/cjs/loader:1098:19) 4:02:54 PM: at require (node:internal/modules/cjs/helpers:108:18) 4:02:54 PM: at Object. (/opt/build/repo/apps/.netlify/plugins/node_modules/@netlify/plugin-nextjs/lib/templates/getHandler.js:14:31) 4:02:54 PM: at Module._compile (node:internal/modules/cjs/loader:1196:14) 4:02:54 PM: ​ 4:02:54 PM: Resolved config 4:02:54 PM: build: 4:02:54 PM: base: /opt/build/repo/apps 4:02:54 PM: command: npm i -g nx@latest && npm i && npm run build check-payments-marketing --configuration=production 4:02:54 PM: commandOrigin: ui 4:02:54 PM: environment: 4:02:54 PM: - NEXT_PUBLIC_MAIL_SERVICE_URL 4:02:54 PM: publish: /opt/build/repo/dist/apps/check-payments-marketing/.next 4:02:54 PM: publishOrigin: ui 4:02:54 PM: plugins: 4:02:54 PM: - inputs: {} 4:02:54 PM: origin: ui 4:02:54 PM: package: '@netlify/plugin-nextjs' 4:02:55 PM: Caching artifacts 4:02:55 PM: Started saving build plugins 4:02:55 PM: Finished saving build plugins 4:02:56 PM: Failed during stage 'building site': Build script returned non-zero exit code: 3 (https://ntl.fyi/exit-code-3) 4:02:55 PM: Started saving pip cache 4:02:55 PM: Finished saving pip cache 4:02:55 PM: Started saving emacs cask dependencies 4:02:55 PM: Finished saving emacs cask dependencies 4:02:55 PM: Started saving maven dependencies 4:02:55 PM: Finished saving maven dependencies 4:02:55 PM: Started saving boot dependencies 4:02:55 PM: Finished saving boot dependencies 4:02:55 PM: Started saving rust rustup cache 4:02:55 PM: Finished saving rust rustup cache 4:02:55 PM: Started saving go dependencies 4:02:55 PM: Finished saving go dependencies 4:02:56 PM: Build failed due to a plugin error: Build script returned non-zero exit code: 3 4:02:56 PM: Failing build: Failed to build site 4:02:56 PM: Finished processing build request in 27.342s

daverodriguez commented 1 year ago

We're seeing the same issue with the release of plugin version 4.33.0. Our dev environment is failing with code that deployed successfully on Wednesday 3/29:

4:24:16 PM: build-image version: 6c82004ef0368b3a0232c6837cead23188bb347e (focal)
4:24:16 PM: buildbot version: 47d1e6bf5eecb8879b17d173eab0e8dc3ea1b589
4:24:16 PM: Building without cache
4:24:16 PM: Starting to prepare the repo for build
4:24:17 PM: No cached dependencies found. Cloning fresh repo
4:24:17 PM: git clone --filter=blob:none [REDACTED]
4:24:17 PM: Preparing Git Reference refs/heads/dev
4:24:20 PM: Parsing package.json dependencies
4:24:21 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'site/.next' versus '.next' in the Netlify UI
4:24:21 PM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'site/netlify/functions' versus 'netlify/functions' in the Netlify UI
4:24:22 PM: Starting to install dependencies
4:24:22 PM: Attempting Node.js version 'v16.13.2' from .nvmrc
4:24:22 PM: Downloading and installing node v16.13.2...
4:24:22 PM: Downloading https://nodejs.org/dist/v16.13.2/node-v16.13.2-linux-x64.tar.xz...
4:24:23 PM: Computing checksum with sha256sum
4:24:23 PM: Checksums matched!
4:24:25 PM: Now using node v16.13.2 (npm v8.1.2)
4:24:25 PM: Enabling Node.js Corepack
4:24:25 PM: Started restoring cached build plugins
4:24:25 PM: Finished restoring cached build plugins
4:24:25 PM: Started restoring cached corepack dependencies
4:24:25 PM: Finished restoring cached corepack dependencies
4:24:25 PM: No npm workspaces detected
4:24:25 PM: Started restoring cached node modules
4:24:25 PM: Finished restoring cached node modules
4:24:25 PM: Installing npm packages using npm version 8.1.2
4:24:27 PM: added 2484 packages in 2s
4:24:27 PM: 303 packages are looking for funding
4:24:27 PM:   run `npm fund` for details
4:24:27 PM: npm packages installed
4:24:27 PM: Python version set to 3.8
4:24:27 PM: Using PHP version 8.0
4:24:28 PM: Attempting Ruby version 2.7.2, read from environment
4:24:28 PM: Using Ruby version 2.7.2
4:24:29 PM: Started restoring cached go cache
4:24:29 PM: Finished restoring cached go cache
4:24:29 PM: Installing Go version 1.19.5 (requested 1.19.5)
4:24:34 PM: go version go1.19.5 linux/amd64
4:24:35 PM: Install dependencies script success
4:24:35 PM: Starting build script
4:24:35 PM: Using stage install dependencies
4:24:35 PM: Detected 1 framework(s)
4:24:35 PM: "next" at version "unknown"
4:24:35 PM: Section completed: initializing
4:24:37 PM: ​
4:24:37 PM:   Netlify Build                                                 
4:24:37 PM: ────────────────────────────────────────────────────────────────
4:24:37 PM: ​
4:24:37 PM: ❯ Version
4:24:37 PM:   @netlify/build 29.9.0
4:24:37 PM: ​
4:24:37 PM: ❯ Flags
4:24:37 PM:   baseRelDir: true
4:24:37 PM:   buildId: 642b35e66b64da760f6f7791
4:24:37 PM:   deployId: 642b35e66b64da760f6f7793
4:24:37 PM: ​
4:24:37 PM: ❯ Current directory
4:24:37 PM:   /opt/build/repo/site
4:24:37 PM: ​
4:24:37 PM: ❯ Config file
4:24:37 PM:   No config file was defined: using default values.
4:24:37 PM: ​
4:24:37 PM: ❯ Context
4:24:37 PM:   production
4:24:37 PM: ​
4:24:37 PM: ❯ Installing plugins
4:24:37 PM:    - @netlify/plugin-nextjs@4.33.0
4:24:46 PM: ​
4:24:46 PM: ❯ Using Next.js Runtime - v4.33.0
4:24:47 PM: ​
4:24:47 PM:   Plugin "@netlify/plugin-nextjs" internal error                
4:24:47 PM: ────────────────────────────────────────────────────────────────
4:24:47 PM: ​
4:24:47 PM:   Error message
4:24:47 PM:   Could not import plugin:
4:24:47 PM:   Error: Could not find Next.js server
4:24:47 PM: ​
4:24:47 PM:   Plugin details
4:24:47 PM:   Package:        @netlify/plugin-nextjs
4:24:47 PM:   Version:        4.33.0
4:24:47 PM:   Repository:     git+https://github.com/netlify/next-runtime.git
4:24:47 PM:   npm link:       https://www.npmjs.com/package/@netlify/plugin-nextjs
4:24:47 PM:   Report issues:  https://github.com/netlify/next-runtime/issues
4:24:47 PM: ​
4:24:47 PM:   Error location
4:24:47 PM:   While loading "@netlify/plugin-nextjs" from Netlify app
4:24:47 PM:       at getNextServer (/opt/build/repo/site/.netlify/plugins/node_modules/@netlify/plugin-nextjs/lib/templates/handlerUtils.js:169:19)
4:24:47 PM:       at Object.<anonymous> (/opt/build/repo/site/.netlify/plugins/node_modules/@netlify/plugin-nextjs/lib/templates/server.js:5:53)
4:24:47 PM:       at Module._compile (node:internal/modules/cjs/loader:1196:14)
4:24:47 PM:       at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
4:24:47 PM:       at Module.load (node:internal/modules/cjs/loader:1074:32)
4:24:47 PM:       at Function.Module._load (node:internal/modules/cjs/loader:909:12)
4:24:47 PM:       at Module.require (node:internal/modules/cjs/loader:1098:19)
4:24:47 PM:       at require (node:internal/modules/cjs/helpers:108:18)
4:24:47 PM:       at Object.<anonymous> (/opt/build/repo/site/.netlify/plugins/node_modules/@netlify/plugin-nextjs/lib/templates/getHandler.js:14:31)
4:24:47 PM:       at Module._compile (node:internal/modules/cjs/loader:1196:14)
4:24:47 PM: ​
4:24:47 PM:   Resolved config
4:24:47 PM:   build:
4:24:47 PM:     base: /opt/build/repo/site
4:24:47 PM:     command: NODE_OPTIONS=--max_old_space_size=4096 npm ci && npm run build
4:24:47 PM:     commandOrigin: ui
4:24:48 PM: Failed during stage 'building site': Build script returned non-zero exit code: 3 (https://ntl.fyi/exit-code-3)
4:24:47 PM:     environment:
4:24:47 PM:       - ALGOLIA_API_KEY
4:24:47 PM:       - ALGOLIA_APP_ID
4:24:47 PM:       - API_BASE
4:24:47 PM:       - API_PREVIEW_TOKEN
4:24:47 PM:       - BLOG_ARTICLES_INDEX_ID
4:24:47 PM:       - CATALOGS_INDEX_ID
4:24:47 PM:       - CONTENTFUL_ACCESS_TOKEN
4:24:47 PM:       - CONTENTFUL_ALGOLIA_UPDATE_KEY
4:24:47 PM:       - CONTENTFUL_ENVIRONMENT
4:24:47 PM:       - CONTENTFUL_MANAGEMENT_ACCESS_TOKEN
4:24:47 PM:       - CONTENTFUL_PREVIEW_ACCESS_TOKEN
4:24:47 PM:       - CONTENTFUL_SPACE_ID
4:24:47 PM:       - ENVIRONMENT
4:24:47 PM:       - FACETS_INDEX_ID
4:24:47 PM:       - GOOGLE_API
4:24:47 PM:       - GOOGLE_GEOCODING_API_KEY
4:24:47 PM:       - GOOGLE_GEOCODING_URL
4:24:47 PM:       - GTM_AUTH
4:24:47 PM:       - GTM_PREVIEW
4:24:47 PM:       - HUBSPOT_API_KEY
4:24:47 PM:       - LOCATIONS_INDEX_ID
4:24:47 PM:       - NETLIFY_GRAPH_TOKEN
4:24:47 PM:       - NEXT_DISABLE_NETLIFY_EDGE
4:24:47 PM:       - NEXT_PUBLIC_GOOGLE_API
4:24:47 PM:       - NODE_VERSION
4:24:47 PM:       - NPM_FLAGS
4:24:47 PM:       - ONEGRAPH_AUTHLIFY_TOKEN
4:24:47 PM:       - PAGES_INDEX_ID
4:24:47 PM:       - PIM_EXPORT_URL
4:24:47 PM:       - POSITIONSTACK_API_KEY
4:24:47 PM:       - POSITIONSTACK_URL
4:24:47 PM:       - PRODUCTS_INDEX_ID
4:24:47 PM:       - SITE_BASE
4:24:47 PM:     publish: /opt/build/repo/site/.next
4:24:47 PM:     publishOrigin: ui
4:24:47 PM:   functionsDirectory: /opt/build/repo/site/netlify/functions
4:24:47 PM:   plugins:
4:24:47 PM:     - inputs: {}
4:24:47 PM:       origin: ui
4:24:47 PM:       package: '@netlify/plugin-nextjs'
4:24:48 PM: Caching artifacts
4:24:48 PM: Started saving node modules
4:24:48 PM: Finished saving node modules
4:24:48 PM: Started saving build plugins
4:24:48 PM: Finished saving build plugins
4:24:48 PM: Started saving corepack cache
4:24:48 PM: Finished saving corepack cache
4:24:48 PM: Started saving pip cache
4:24:48 PM: Finished saving pip cache
4:24:48 PM: Started saving emacs cask dependencies
4:24:48 PM: Finished saving emacs cask dependencies
4:24:48 PM: Started saving maven dependencies
4:24:48 PM: Finished saving maven dependencies
4:24:48 PM: Started saving boot dependencies
4:24:48 PM: Finished saving boot dependencies
4:24:48 PM: Started saving rust rustup cache
4:24:48 PM: Finished saving rust rustup cache
4:24:48 PM: Started saving go dependencies
4:24:48 PM: Finished saving go dependencies
4:24:48 PM: Build failed due to a plugin error: Build script returned non-zero exit code: 3
4:24:48 PM: Failing build: Failed to build site
4:24:49 PM: Finished processing build request in 32.239s

Comparing to the output from last week, this is the most obvious difference I see:

4:24:35 PM: "next" at version "unknown"

vs. previous build:

5:36:09 PM: "next" at version "12.3.4"
nickytonline commented 1 year ago

@joeluna17 @daverodriguez aside from using the latest version of the plugin, have you updated Next.js recently?

omniphx commented 1 year ago

@nickytonline Same thing is happening to us. Upgraded to Next v13 about 4 weeks ago and haven't touched it since (Using yarn pnp).

Started seeing builds failing March 29th at 9:40am PT. Last successful build was March 28th at 3:09pm PT.

orinokai commented 1 year ago

hi @joeluna17, could you please let me know if you are using a monorepo setup? if so, it would very useful to know your tooling setup, folder structure and netlify.toml setup. thanks!

daverodriguez commented 1 year ago

@joeluna17 @daverodriguez aside from using the latest version of the plugin, have you updated Next.js recently?

@nickytonline No, our Next.js version has been stable since December of last year.

pieh commented 1 year ago

Some additional information that might be helpful to us to narrow down where the issue was introduced:

What versions of @netlify/build and @netlify/plugin-nextjs were logged on last successful builds vs what's logged on currently failing builds?

omniphx commented 1 year ago

@pieh

Last successful build on March 28th at 3:09pm PT:

3:10:07 PM:   Netlify Build                                                 
3:10:07 PM: ────────────────────────────────────────────────────────────────
3:10:07 PM: ​
3:10:07 PM: ❯ Version
3:10:07 PM:   @netlify/build 29.8.0
3:10:07 PM: ​
3:10:07 PM: ❯ Flags
3:10:07 PM:   baseRelDir: true
3:10:07 PM:   buildId: 6423659120531d0008b0af5e
3:10:07 PM:   deployId: 6423659120531d0008b0af60
3:10:07 PM: ​
3:10:07 PM: ❯ Current directory
3:10:07 PM:   /opt/build/repo
3:10:07 PM: ​
3:10:07 PM: ❯ Config file
3:10:07 PM:   /opt/build/repo/netlify.toml
3:10:07 PM: ​
3:10:07 PM: ❯ Context
3:10:07 PM:   deploy-preview
3:10:07 PM: ​
3:10:07 PM: ❯ Installing plugins
3:10:07 PM:    - @netlify/plugin-nextjs@4.32.2

First build error on March 29th at 9:40am PT:

9:40:51 AM:   Netlify Build                                                 
9:40:51 AM: ────────────────────────────────────────────────────────────────
9:40:51 AM: ​
9:40:51 AM: ❯ Version
9:40:51 AM:   @netlify/build 29.8.0
9:40:51 AM: ​
9:40:51 AM: ❯ Flags
9:40:51 AM:   baseRelDir: true
9:40:51 AM:   buildId: 642469ebba18d60008f3d795
9:40:51 AM:   deployId: 642469ebba18d60008f3d797
9:40:51 AM: ​
9:40:51 AM: ❯ Current directory
9:40:51 AM:   /opt/build/repo
9:40:51 AM: ​
9:40:51 AM: ❯ Config file
9:40:51 AM:   /opt/build/repo/netlify.toml
9:40:51 AM: ​
9:40:51 AM: ❯ Context
9:40:51 AM:   production
9:40:51 AM: ​
9:40:51 AM: ❯ Installing plugins
9:40:51 AM:    - @netlify/plugin-nextjs@4.33.0
9:40:59 AM: ​
9:40:59 AM: ❯ Using Next.js Runtime - v4.33.0
9:41:00 AM: ​
9:41:00 AM:   Plugin "@netlify/plugin-nextjs" internal error                
9:41:00 AM: ────────────────────────────────────────────────────────────────
9:41:00 AM: ​
9:41:00 AM:   Error message
9:41:00 AM:   Could not import plugin:
9:41:00 AM:   Error: Could not find Next.js server
9:41:00 AM: ​
9:41:00 AM:   Plugin details
9:41:00 AM:   Package:        @netlify/plugin-nextjs
9:41:00 AM:   Version:        4.33.0
9:41:00 AM:   Repository:     git+https://github.com/netlify/next-runtime.git
9:41:00 AM:   npm link:       https://www.npmjs.com/package/@netlify/plugin-nextjs
9:41:00 AM:   Report issues:  https://github.com/netlify/next-runtime/issues
9:41:00 AM: ​
9:41:00 AM:   Error location
9:41:00 AM:   While loading "@netlify/plugin-nextjs" from Netlify app
9:41:00 AM:       at getNextServer (/opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/lib/templates/handlerUtils.js:169:19)
9:41:00 AM:       at Object.<anonymous> (/opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/lib/templates/server.js:5:53)
9:41:00 AM:       at Module._compile (node:internal/modules/cjs/loader:1191:14)
9:41:00 AM:       at Object.Module._extensions..js (node:internal/modules/cjs/loader:1245:10)
9:41:00 AM:       at Module.load (node:internal/modules/cjs/loader:1069:32)
9:41:00 AM:       at Function.Module._load (node:internal/modules/cjs/loader:904:12)
9:41:00 AM:       at Module.require (node:internal/modules/cjs/loader:1093:19)
9:41:00 AM:       at require (node:internal/modules/cjs/helpers:108:18)
9:41:00 AM:       at Object.<anonymous> (/opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/lib/templates/getHandler.js:14:31)
9:41:00 AM:       at Module._compile (node:internal/modules/cjs/loader:1191:14)
9:41:00 AM: ​
9:41:00 AM:   Resolved config
9:41:00 AM:   build:
9:41:00 AM:     command: yarn clean && yarn build:staging
9:41:00 AM:     commandOrigin: ui
9:41:00 AM:     environment:
9:41:00 AM:       - ENABLE_BROWSER_MONITORING
9:41:00 AM:       - NETLIFY_GRAPH_TOKEN
9:41:00 AM:       - NETLIFY_NEXT_PLUGIN_SKIP
9:41:00 AM:       - NEWRELIC_ACCOUNT_ID
9:41:00 AM:       - NEWRELIC_APP_ID
9:41:00 AM:       - NEWRELIC_BROWSER_LICENSE_KEY
9:41:00 AM:       - NEWRELIC_INGEST_LICENSE_KEY
9:41:00 AM:       - NEXT_PUBLIC_SENTRY_DSN
9:41:00 AM:       - NEXT_PUBLIC_SENTRY_ENV
9:41:00 AM:       - NODE_OPTIONS
9:41:00 AM:       - ONEGRAPH_AUTHLIFY_TOKEN
9:41:00 AM:       - SENTRY_AUTH_TOKEN
9:41:00 AM:       - SENTRY_ORG
9:41:00 AM:       - SENTRY_PROJECT
9:41:00 AM:       - NEXT_PUBLIC_IS_PR_PREVIEW
9:41:00 AM:       - NODE_VERSION
9:41:00 AM:     publish: /opt/build/repo/apps/frontend/out
9:41:00 AM:     publishOrigin: config
9:41:00 AM:   functionsDirectory: /opt/build/repo/netlify/functions
9:41:00 AM:   plugins:
9:41:00 AM:     - inputs: {}
9:41:03 AM: Failed during stage 'building site': Build script returned non-zero exit code: 3 (https://ntl.fyi/exit-code-3)
9:41:00 AM:       origin: ui
9:41:00 AM:       package: '@netlify/plugin-nextjs'
9:41:01 AM: Caching artifacts
9:41:01 AM: Started saving node modules
9:41:01 AM: Finished saving node modules
9:41:01 AM: Started saving build plugins
9:41:01 AM: Finished saving build plugins
9:41:01 AM: Started saving corepack cache
9:41:01 AM: Finished saving corepack cache
9:41:01 AM: Started saving yarn cache
9:41:01 AM: Finished saving yarn cache
9:41:01 AM: Started saving pip cache
9:41:01 AM: Finished saving pip cache
9:41:01 AM: Started saving emacs cask dependencies
9:41:01 AM: Finished saving emacs cask dependencies
9:41:01 AM: Started saving maven dependencies
9:41:01 AM: Finished saving maven dependencies
9:41:01 AM: Started saving boot dependencies
9:41:01 AM: Finished saving boot dependencies
9:41:01 AM: Started saving rust rustup cache
9:41:01 AM: Finished saving rust rustup cache
9:41:01 AM: Started saving go dependencies
9:41:01 AM: Finished saving go dependencies
9:41:03 AM: Build failed due to a plugin error: Build script returned non-zero exit code: 3
9:41:03 AM: Failing build: Failed to build site
9:41:03 AM: Finished processing build request in 46.95s
[Docs](https://docs.netlify.com/)
[Pricing](https://www.netlify.com/pricing/)
[Support](https://www.netlify.com/support/)
[Blog](https://www.netlify.com/blog/)
[Changelog](https://www.netlify.com/blog/tags/changelog/)
pieh commented 1 year ago

Could you try adding

"@netlify/plugin-nextjs": "4.33.1-lazy-server-import.0"

to devDependencies in package.json of your site (would suggest doing pull request and not just pushing to production branch as it might break the site runtime)? If builds is successful, please also check if ISR and/or SSR pages do work, because it might just move the problem from build to actual runtime

Above canary was build with those changes https://github.com/netlify/next-runtime/compare/lazy-import-server

Edit: you might also use above devDependencies technique to downgrade to 4.32.2 and see if that starts to work - that at least will tell us that it's for sure problem in next-runtime and not outside of it

kindrift-vt commented 1 year ago

@pieh I'm running into the same issue on my nextjs deploys as well. Used to work and not getting this same error. I tried adding the plugin explicitly using the specific version you listed but that did not work. I also tried to ddowngrade to 4.32.2 and no go there as well

nuotsu commented 1 year ago

local builds (next build + next start) and Netlify builds succeed on Next.js v13.3.0 but the actual *.netlify.app URL shows 404 Next.js error pages.

I've downgraded back to Next.js v13.1.6 and everything is back to normal working conditions.

KrustyC commented 1 year ago

I also started getting an issue as soon as I upgraded my repo to Next 13.3 and @netlify/plugin-nextjs to "4.34.0". Downgrading Next back to 13.2.1 and @netlify/plugin-nextjs to "^4.29.5-appdir.0" solved the issue straightaway.

joeluna17 commented 1 year ago

hi @joeluna17, could you please let me know if you are using a monorepo setup? if so, it would very useful to know your tooling setup, folder structure and netlify.toml setup. thanks!

I am using NX monorepo and the folder structure is as follows : apps (root) -> app1 , app2, app3... I have no toml file as I'm using the GUI to configure the Build and Deploy settings in Netlify. This was all working fine a month ago and then the plugin version incremented. Also, I have not upgraded my Next version still on V13.1.1

pieh commented 1 year ago

I also started getting an issue as soon as I upgraded my repo to Next 13.3 and @netlify/plugin-nextjs to "4.34.0". Downgrading Next back to 13.2.1 and @netlify/plugin-nextjs to "^4.29.5-appdir.0" solved the issue straightaway.

@KrustyC I was not able to reproduce problems with your reproduction when going back to Next 13.3 and @netlify/plugin-nextjs 4.34.0 :/ (I did need to make some component changes to skip contentful data fetching as I don't have credentials for your space and while I don't expect this to be reason for why I can't reproduce - it's always possibility as I didn't run code exactly as-is)

I am using NX monorepo and the folder structure is as follows : apps (root) -> app1 , app2, app3... I have no toml file as I'm using the GUI to configure the Build and Deploy settings in Netlify. This was all working fine a month ago and then the plugin version incremented. Also, I have not upgraded my Next version still on V13.1.1

Can you provide settings that you used in GUI? I did try to replicate it with some basic NX setup, but all of my test deploys that I could think of were successful

KrustyC commented 1 year ago

@pieh thanks for giving it a go. Have you tried building the app with npm run build? Because the code runs just fine when I do npm run dev but it fails when I do the build. Also I haven't tried it without the data fetching components, I may give that a go and see if that is indeed the issue

pieh commented 1 year ago

@KrustyC I was using netlify build locally which does run npm run build (due to https://github.com/KrustyC/thescrapbookers.blog/blob/4f242989947bcca15ae83abd7d5eb7d22cdadd6c/netlify.toml#L2 ).

I do see an error related to edge function packaging, but this is not related to Could not find Next.js server error that other folks are reporting here

KrustyC commented 1 year ago

I finally managed to solve the issue, which also solved an issue with my Middleware not running.

I am not sure it is ideal, but it works fine in my case: all I had to do was to add NEXT_DISABLE_NETLIFY_EDGE=true in my .env.local file. I also added it to the Environment variables in Netlify eland now the website builds fine, both from local and in Netlify

orinokai commented 1 year ago

@KrustyC glad that's got you a working build. if you want to continue trying to resolve it, i'd recommend adding a TOML file that cds into the relevant directory during the build

KrustyC commented 1 year ago

@orinokai I am not sure which folder I should cd into. The build in Netlify always worked and I think it is building from the root folder of my project, which is indeed the right folder from which it should build my project

levino commented 1 year ago

I have the same issue. Looks like a yarn and pnp issue. I fixed it by using nodeLinker: node-modules for the time being. Please see the repository at the parent commit for a reproduction of the issue. Screenshot 2023-04-19 at 12 22 48

When I downgraded the netlify plugin, I saw more telling output:

Error: @netlify/esbuild tried to access esbuild, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
pieh commented 1 year ago

@levino unfortunately Yarn PnP doesn't play well with build plugins (see notes in https://docs.netlify.com/configure-builds/manage-dependencies/#yarn )

For cases other than Yarn PnP and Could not find Next.js server error:

I did find a way to reproduce the problem finally and above fixed my reproduction and with changes from https://github.com/netlify/next-runtime/pull/2059 was able to successfully build and serve the site

If you are willing to test those changes - please try adding following

"@netlify/plugin-nextjs": "4.35.1-next-server-fix.0"

to devDependencies in package.json and let us know of results

marksikaundi commented 1 year ago

i have the same errors too, how did you solve it, i can't understand the website been deployed but all the sudden it stop