Deployments have failed ever since upgrading Nextjs to latest

Hi there,

Ever since I upgraded to the latest version of Nextjs, my site doesn’t deploy :frowning:

The repo is github.com/timfee/homepage

Running netlify build on my local machine works fine.

Any thoughts would be much appreciated! :pray:

❯ netlify build                                        homepage/www -> master !

┌─────────────────────────────┐
│        Netlify Build        │
└─────────────────────────────┘

❯ Version
  @netlify/build 4.8.4

❯ Flags
  mode: cli

❯ Current directory
  /Users/timfee/Developer/homepage/www

❯ Config file
  No config file was defined: using default values.

❯ Context
  production

❯ Installing plugins
   - netlify-plugin-cache-nextjs
   - netlify-plugin-inline-source
   - netlify-plugin-submit-sitemap

❯ Loading plugins
   - netlify-plugin-cache-nextjs@1.5.2 from Netlify app
   - netlify-plugin-inline-source@1.0.4 from Netlify app
   - netlify-plugin-submit-sitemap@0.2.2 from Netlify app

┌────────────────────────────────────────────────────────┐
│ 1. onPreBuild command from netlify-plugin-cache-nextjs │
└────────────────────────────────────────────────────────┘

.next/cache exists on disk
Couldn't restore the cache for the .next folder at the location `.next/cache`

(netlify-plugin-cache-nextjs onPreBuild completed in 362ms)

┌───────────────────────────────────┐
│ 2. Build command from Netlify app │
└───────────────────────────────────┘

$ npm run-script build && npm run-script export

> timfeeley.com@1.2.3 build /Users/timfee/Developer/homepage/www
> next build

info  - Loaded env from /Users/timfee/Developer/homepage/www/.env.local
warn  - You have enabled experimental feature(s).
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.

info  - Creating an optimized production build
info  - Compiled successfully
info  - Collecting page data
info  - Generating static pages (7/7)
info  - Finalizing page optimization

Page                                                                  Size     First Load JS
┌ ○ /                                                                 4.88 kB        65.1 kB
├   /_app                                                             0 B            56.9 kB
├ ○ /404                                                              2.29 kB        59.2 kB
├ ○ /bio                                                              4.69 kB        64.9 kB
├ ● /posts                                                            2.04 kB        62.3 kB
├ ○ /posts/people-friendly-product-reviews                            9.8 kB         81.5 kB
├ ○ /posts/practical-pm-interviewing-tips                             5.05 kB        76.8 kB
└ ○ /posts/what-to-do-when-you-dont-know-what-to-do                   3.82 kB        75.6 kB
+ First Load JS shared by all                                         56.9 kB
  ├ chunks/8cac0ed93000786265b7da44769ab0cfa267845f.a4bf19.module.js  6.13 kB
  ├ chunks/framework.53cfa6.module.js                                 40.2 kB
  ├ chunks/main.362262.module.js                                      6.37 kB
  ├ chunks/pages/_app.4fa8f9.module.js                                3.51 kB
  └ chunks/webpack.07c5bc.module.js                                   751 B

λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
○  (Static)  automatically rendered as static HTML (uses no initial props)
●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
   (ISR)     incremental static regeneration (uses revalidate in getStaticProps)


> timfeeley.com@1.2.3 postbuild /Users/timfee/Developer/homepage/www
> next-sitemap


> timfeeley.com@1.2.3 export /Users/timfee/Developer/homepage/www
> npm run build && next export


> timfeeley.com@1.2.3 build /Users/timfee/Developer/homepage/www
> next build

info  - Loaded env from /Users/timfee/Developer/homepage/www/.env.local
warn  - You have enabled experimental feature(s).
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.

info  - Creating an optimized production build
info  - Compiled successfully
info  - Collecting page data
info  - Generating static pages (7/7)
info  - Finalizing page optimization

Page                                                                  Size     First Load JS
┌ ○ /                                                                 4.88 kB        65.1 kB
├   /_app                                                             0 B            56.9 kB
├ ○ /404                                                              2.29 kB        59.2 kB
├ ○ /bio                                                              4.69 kB        64.9 kB
├ ● /posts                                                            2.04 kB        62.3 kB
├ ○ /posts/people-friendly-product-reviews                            9.8 kB         81.5 kB
├ ○ /posts/practical-pm-interviewing-tips                             5.05 kB        76.8 kB
└ ○ /posts/what-to-do-when-you-dont-know-what-to-do                   3.82 kB        75.6 kB
+ First Load JS shared by all                                         56.9 kB
  ├ chunks/8cac0ed93000786265b7da44769ab0cfa267845f.a4bf19.module.js  6.13 kB
  ├ chunks/framework.53cfa6.module.js                                 40.2 kB
  ├ chunks/main.362262.module.js                                      6.37 kB
  ├ chunks/pages/_app.4fa8f9.module.js                                3.51 kB
  └ chunks/webpack.07c5bc.module.js                                   751 B

λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
○  (Static)  automatically rendered as static HTML (uses no initial props)
●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
   (ISR)     incremental static regeneration (uses revalidate in getStaticProps)


> timfeeley.com@1.2.3 postbuild /Users/timfee/Developer/homepage/www
> next-sitemap

info  - Loaded env from /Users/timfee/Developer/homepage/www/.env.local
warn  - You have enabled experimental feature(s).
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.

info  - using build directory: /Users/timfee/Developer/homepage/www/.next
info  - Copying "static build" directory
info  - No "exportPathMap" found in "next.config.js". Generating map from "./pages"
info  - Launching 11 workers
info  - Copying "public" directory
info  - undefined (7/7)
Export successful

(build.command completed in 31.5s)

┌─────────────────────────────────────────────────────────┐
│ 3. onPostBuild command from netlify-plugin-cache-nextjs │
└─────────────────────────────────────────────────────────┘

.next/cache exists on disk
Cached the .next folder at the location `.next/cache`

(netlify-plugin-cache-nextjs onPostBuild completed in 677ms)

┌──────────────────────────────────────────────────────────┐
│ 4. onPostBuild command from netlify-plugin-inline-source │
└──────────────────────────────────────────────────────────┘

Sources successfully inlined!

(netlify-plugin-inline-source onPostBuild completed in 14ms)

┌─────────────────────────────────────────────────────────┐
│ 5. onSuccess command from netlify-plugin-submit-sitemap │
└─────────────────────────────────────────────────────────┘

Going to submit sitemap to google
Going to submit sitemap to bing
Going to submit sitemap to yandex
 ✓  DONE! Sitemap submitted succesfully to google
 ✓  DONE! Sitemap submitted succesfully to bing
 ✓  DONE! Sitemap submitted succesfully to yandex

(netlify-plugin-submit-sitemap onSuccess completed in 785ms)

┌─────────────────────────────┐
│           Summary           │
└─────────────────────────────┘

❯ Plugin netlify-plugin-submit-sitemap ran successfully
  Sitemap submitted succesfully
  ✓  DONE! Sitemap submitted succesfully to google
  ✓  DONE! Sitemap submitted succesfully to bing
  ✓  DONE! Sitemap submitted succesfully to yandex

┌─────────────────────────────┐
│   Netlify Build Complete    │
└─────────────────────────────┘

(Netlify Build completed in 41.5s)

The failing Netlify console reads:

5:27:12 PM: Build ready to start
5:27:14 PM: build-image version: b0258b965567defc4a2d7e2f2dec2e00c8f73ad6
5:27:14 PM: build-image tag: v3.4.1
5:27:14 PM: buildbot version: c6376102eedf4be6c6e5d685c7141e2eb612d47d
5:27:14 PM: Fetching cached dependencies
5:27:14 PM: Starting to download cache of 156.4MB
5:27:18 PM: Finished downloading cache in 4.036388077s
5:27:18 PM: Starting to extract cache
5:27:27 PM: Finished extracting cache in 8.683196549s
5:27:27 PM: Finished fetching cache in 12.811309786s
5:27:27 PM: Starting to prepare the repo for build
5:27:27 PM: Preparing Git Reference refs/heads/master
5:27:30 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'www/out' versus 'out' in the Netlify UI
5:27:30 PM: Starting build script
5:27:30 PM: Installing dependencies
5:27:30 PM: Python version set to 2.7
5:27:31 PM: Started restoring cached node version
5:27:35 PM: Finished restoring cached node version
5:27:36 PM: v12.18.0 is already installed.
5:27:38 PM: Now using node v12.18.0 (npm v6.14.4)
5:27:38 PM: Started restoring cached build plugins
5:27:38 PM: Finished restoring cached build plugins
5:27:38 PM: Attempting ruby version 2.7.1, read from environment
5:27:40 PM: Using ruby version 2.7.1
5:27:41 PM: Using PHP version 5.6
5:27:41 PM: 5.2 is already installed.
5:27:41 PM: Using Swift version 5.2
5:27:41 PM: Started restoring cached node modules
5:27:41 PM: Finished restoring cached node modules
5:27:41 PM: Installing NPM modules using NPM version 6.14.4
5:28:00 PM: npm WARN @typescript-eslint/eslint-plugin@2.34.0 requires a peer of @typescript-eslint/parser@^2.0.0 but none is installed. You must install peer dependencies yourself.
5:28:00 PM: npm WARN timfeeley.com@1.2.3 No description
5:28:00 PM: npm WARN timfeeley.com@1.2.3 No repository field.
5:28:00 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/fsevents):
5:28:00 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:28:00 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/webpack/node_modules/fsevents):
5:28:00 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:28:00 PM: added 16 packages from 5 contributors, removed 8 packages, updated 25 packages and audited 1340 packages in 17.054s
5:28:01 PM: 139 packages are looking for funding
5:28:01 PM:   run `npm fund` for details
5:28:01 PM: found 3 low severity vulnerabilities
5:28:01 PM:   run `npm audit fix` to fix them, or `npm audit` for details
5:28:01 PM: NPM modules installed
5:28:01 PM: Started restoring cached go cache
5:28:01 PM: Finished restoring cached go cache
5:28:01 PM: go version go1.14.4 linux/amd64
5:28:01 PM: go version go1.14.4 linux/amd64
5:28:01 PM: Installing missing commands
5:28:01 PM: Verify run directory
5:28:03 PM: ​
5:28:03 PM: ┌─────────────────────────────┐
5:28:03 PM: │        Netlify Build        │
5:28:03 PM: └─────────────────────────────┘
5:28:03 PM: ​
5:28:03 PM: ❯ Version
5:28:03 PM:   @netlify/build 4.8.1
5:28:03 PM: ​
5:28:03 PM: ❯ Flags
5:28:03 PM:   deployId: 5f7fae607d31bc00088d68fb
5:28:03 PM:   mode: buildbot
5:28:03 PM: ​
5:28:03 PM: ❯ Current directory
5:28:03 PM:   /opt/build/repo/www
5:28:03 PM: ​
5:28:03 PM: ❯ Config file
5:28:03 PM:   No config file was defined: using default values.
5:28:03 PM: ​
5:28:03 PM: ❯ Context
5:28:03 PM:   production
5:28:03 PM: ​
5:28:03 PM: ❯ Loading plugins
5:28:03 PM:    - netlify-plugin-cache-nextjs@1.4.0 from Netlify app
5:28:03 PM:    - netlify-plugin-inline-source@1.0.4 from Netlify app
5:28:03 PM:    - netlify-plugin-submit-sitemap@0.2.2 from Netlify app
5:28:03 PM: ​
5:28:03 PM: ┌────────────────────────────────────────────────────────┐
5:28:03 PM: │ 1. onPreBuild command from netlify-plugin-cache-nextjs │
5:28:03 PM: └────────────────────────────────────────────────────────┘
5:28:03 PM: ​
5:28:04 PM: Restored the cached .next folder at the location `.next/cache`
5:28:04 PM: ​
5:28:04 PM: (netlify-plugin-cache-nextjs onPreBuild completed in 679ms)
5:28:04 PM: ​
5:28:04 PM: ┌───────────────────────────────────┐
5:28:04 PM: │ 2. Build command from Netlify app │
5:28:04 PM: └───────────────────────────────────┘
5:28:04 PM: ​
5:28:04 PM: $ npm run-script build && npm run-script export
5:28:04 PM: > timfeeley.com@1.2.3 build /opt/build/repo/www
5:28:04 PM: > next build
5:28:06 PM: warn  - You have enabled experimental feature(s).
5:28:06 PM: warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.
5:28:06 PM: info  - Creating an optimized production build...
5:28:43 PM: Failed to compile.
5:28:43 PM: 
5:28:43 PM: Error: Can't resolve '/fonts/SpaceGrotesk-Bold.woff2' in '/opt/build/repo/www/src/css'
5:28:43 PM: > Build error occurred
5:28:43 PM: Error: > Build failed because of webpack errors
5:28:43 PM:     at build (/opt/build/repo/www/node_modules/next/dist/build/index.js:15:918)
5:28:43 PM: npm ERR! code ELIFECYCLE
5:28:43 PM: npm ERR! errno 1
5:28:43 PM: npm ERR! timfeeley.com@1.2.3 build: `next build`
5:28:43 PM: npm ERR! Exit status 1
5:28:43 PM: npm ERR!
5:28:43 PM: npm ERR! Failed at the timfeeley.com@1.2.3 build script.
5:28:43 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
5:28:43 PM: npm ERR! A complete log of this run can be found in:
5:28:43 PM: npm ERR!     /opt/buildhome/.npm/_logs/2020-10-09T00_28_43_317Z-debug.log
5:28:43 PM: ​
5:28:43 PM: ┌─────────────────────────────┐
5:28:43 PM: │   "build.command" failed    │
5:28:43 PM: └─────────────────────────────┘
5:28:43 PM: ​
5:28:43 PM:   Error message
5:28:43 PM:   Command failed with exit code 1: npm run-script build && npm run-script export
5:28:43 PM: ​
5:28:43 PM:   Error location
5:28:43 PM:   In Build command from Netlify app:
5:28:43 PM:   npm run-script build && npm run-script export
5:28:43 PM: ​
5:28:43 PM:   Resolved config
5:28:43 PM:   build:
5:28:43 PM:     base: /opt/build/repo/www
5:28:43 PM:     command: npm run-script build && npm run-script export
5:28:43 PM:     commandOrigin: ui
5:28:43 PM:     environment:
5:28:43 PM:       - API_URL
5:28:43 PM:       - GAPI_CLIENT
5:28:43 PM:       - GAPI_TOKEN
5:28:43 PM:       - TWITTER_API_KEY
5:28:43 PM:       - TWITTER_API_SECRET
5:28:43 PM:       - TWITTER_TOKEN
5:28:43 PM:     publish: /opt/build/repo/www/out
5:28:43 PM:   plugins:
5:28:43 PM:     - inputs: {}
5:28:43 PM:       origin: ui
5:28:43 PM:       package: netlify-plugin-cache-nextjs
5:28:43 PM:     - inputs: {}
5:28:43 PM:       origin: ui
5:28:43 PM:       package: netlify-plugin-inline-source
5:28:43 PM:     - inputs: {}
5:28:43 PM:       origin: ui
5:28:43 PM:       package: netlify-plugin-submit-sitemap
5:28:43 PM: Caching artifacts
5:28:43 PM: Started saving node modules
5:28:43 PM: Finished saving node modules
5:28:43 PM: Started saving build plugins
5:28:43 PM: Finished saving build plugins
5:28:43 PM: Started saving pip cache
5:28:43 PM: Finished saving pip cache
5:28:43 PM: Started saving emacs cask dependencies
5:28:43 PM: Finished saving emacs cask dependencies
5:28:43 PM: Started saving maven dependencies
5:28:43 PM: Finished saving maven dependencies
5:28:43 PM: Started saving boot dependencies
5:28:43 PM: Finished saving boot dependencies
5:28:43 PM: Started saving go dependencies
5:28:43 PM: Finished saving go dependencies
5:28:43 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:28:43 PM: Failing build: Failed to build site
5:28:43 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
5:28:43 PM: Finished processing build request in 1m29.434715277s

Hey Tim!

Do these node versions look the same as what you are running locally (and do you use npm rather than yarn)? They are both quotes from your Netlify build:

5:27:38 PM: Now using node v12.18.0 (npm v6.14.4)
5:27:41 PM: Installing NPM modules using NPM version 6.14.4

Either way, this is where we ask folks to start with build debugging:


(which links to https://docs.netlify.com/configure-builds/troubleshooting-tips/ that is also good reading)

Take a look and let me know at a minimum, the answers to the last questions in that Support guide as it is our first steps in helping you debug errors. In particular, the case sensitivity of filenames is described in those articles in detail and may be related to judge from the error message:

5:28:43 PM: Error: Can't resolve '/fonts/SpaceGrotesk-Bold.woff2' in '/opt/build/repo/www/src/css'
(also - there is no /fonts - make sure you are using relative paths :))

Thanks for the reply!

It looks like this was a Next issue, resolved in the latest release: https://github.com/vercel/next.js/issues/17756#issuecomment-706371790

1 Like