Build failing due to baseUrl not working?

Next.js build is failing for site name local328-dashboard-staging. Build succeeds locally. Error seems to indicate baseUrl setting in tsconfig.json is not working. I tried both this "baseUrl": "." as per https://www.netlify.com/blog/2020/05/18/handy-new-features-in-next.js-9.4/ and "baseUrl": "./" as per https://www.netlify.com/blog/2020/12/07/absolute-imports-in-next.js/. Here is the build log:

11:43:38 AM: Build ready to start
11:43:41 AM: build-image version: 0582042f4fc261adc7bd8333f34884959c577302
11:43:41 AM: build-image tag: v3.7.6
11:43:41 AM: buildbot version: a994ee5c50dd79b03ccea38d9607b1870e04e567
11:43:41 AM: Fetching cached dependencies
11:43:41 AM: Starting to download cache of 199.4MB
11:43:42 AM: Finished downloading cache in 1.615184746s
11:43:42 AM: Starting to extract cache
11:43:53 AM: Finished extracting cache in 10.688918519s
11:43:53 AM: Finished fetching cache in 12.407557095s
11:43:53 AM: Starting to prepare the repo for build
11:43:54 AM: Preparing Git Reference refs/heads/staging
11:43:55 AM: Parsing package.json dependencies
11:43:56 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'out' versus 'out/' in the Netlify UI
11:43:57 AM: Starting build script
11:43:57 AM: Installing dependencies
11:43:57 AM: Python version set to 2.7
11:43:58 AM: Started restoring cached node version
11:44:02 AM: Finished restoring cached node version
11:44:03 AM: v12.18.0 is already installed.
11:44:04 AM: Now using node v12.18.0 (npm v6.14.4)
11:44:04 AM: Started restoring cached build plugins
11:44:04 AM: Finished restoring cached build plugins
11:44:05 AM: Attempting ruby version 2.7.1, read from environment
11:44:07 AM: Using ruby version 2.7.1
11:44:08 AM: Using PHP version 5.6
11:44:08 AM: Started restoring cached yarn cache
11:44:08 AM: Finished restoring cached yarn cache
11:44:09 AM: No yarn workspaces detected
11:44:09 AM: Started restoring cached node modules
11:44:09 AM: Finished restoring cached node modules
11:44:09 AM: Installing NPM modules using Yarn version 1.22.4
11:44:11 AM: yarn install v1.22.4
11:44:11 AM: [1/4] Resolving packages...
11:44:11 AM: [2/4] Fetching packages...
11:44:34 AM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
11:44:34 AM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
11:44:34 AM: [3/4] Linking dependencies...
11:44:34 AM: warning "@emotion/styled > @emotion/babel-plugin@11.3.0" has unmet peer dependency "@babel/core@^7.0.0".
11:44:34 AM: warning "@emotion/styled > @emotion/babel-plugin > @babel/plugin-syntax-jsx@7.12.13" has unmet peer dependency "@babel/core@^7.0.0-0".
11:44:44 AM: [4/4] Building fresh packages...
11:44:44 AM: Done in 33.85s.
11:44:45 AM: NPM modules installed using Yarn
11:44:45 AM: Started restoring cached go cache
11:44:45 AM: Finished restoring cached go cache
11:44:45 AM: go version go1.14.4 linux/amd64
11:44:45 AM: go version go1.14.4 linux/amd64
11:44:45 AM: Installing missing commands
11:44:45 AM: Verify run directory
11:44:48 AM: ​
11:44:48 AM: ────────────────────────────────────────────────────────────────
11:44:48 AM:   Netlify Build                                                 
11:44:48 AM: ────────────────────────────────────────────────────────────────
11:44:48 AM: ​
11:44:48 AM: ❯ Version
11:44:48 AM:   @netlify/build 11.18.1
11:44:48 AM: ​
11:44:48 AM: ❯ Flags
11:44:48 AM:   deployId: 60abf3da5bc2f600077dfb06
11:44:48 AM: ​
11:44:48 AM: ❯ Current directory
11:44:48 AM:   /opt/build/repo
11:44:48 AM: ​
11:44:48 AM: ❯ Config file
11:44:48 AM:   No config file was defined: using default values.
11:44:48 AM: ​
11:44:48 AM: ❯ Context
11:44:48 AM:   production
11:44:48 AM: ​
11:44:48 AM: ❯ Installing plugins
11:44:48 AM:    - @netlify/plugin-nextjs@3.3.0
11:45:13 AM: ​
11:45:13 AM: ❯ Loading plugins
11:45:13 AM:    - @netlify/plugin-nextjs@3.3.0 from Netlify app
11:45:13 AM: ​
11:45:13 AM: ────────────────────────────────────────────────────────────────
11:45:13 AM:   1. onPreBuild command from @netlify/plugin-nextjs             
11:45:13 AM: ────────────────────────────────────────────────────────────────
11:45:13 AM: ​
11:45:13 AM: info  - Using webpack 5. Reason: no custom webpack configuration in next.config.js https://nextjs.org/docs/messages/webpack5
11:45:16 AM: Next.js cache restored.
11:45:16 AM: ​
11:45:16 AM: (@netlify/plugin-nextjs onPreBuild completed in 2.6s)
11:45:16 AM: ​
11:45:16 AM: ────────────────────────────────────────────────────────────────
11:45:16 AM:   2. Build command from Netlify app                             
11:45:16 AM: ────────────────────────────────────────────────────────────────
11:45:16 AM: ​
11:45:16 AM: $ yarn build
11:45:16 AM: yarn run v1.22.4
11:45:16 AM: $ next build
11:45:17 AM: info  - Using webpack 5. Reason: no custom webpack configuration in next.config.js https://nextjs.org/docs/messages/webpack5
11:45:17 AM: info  - Checking validity of types...
11:45:25 AM: Failed to compile.
11:45:25 AM: 
11:45:25 AM: ./pages/404.tsx:1:18
11:45:25 AM: Type error: Cannot find module 'components/Head' or its corresponding type declarations.
11:45:25 AM: > 1 | import Head from 'components/Head'
11:45:25 AM:     |                  ^
11:45:25 AM:   2 | 
11:45:25 AM:   3 | const PageNotFound = (): JSX.Element => (
11:45:25 AM:   4 |   <>
11:45:25 AM: error Command failed with exit code 1.
11:45:25 AM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
11:45:25 AM: ​
11:45:25 AM: ────────────────────────────────────────────────────────────────
11:45:25 AM:   "build.command" failed                                        
11:45:25 AM: ────────────────────────────────────────────────────────────────
11:45:25 AM: ​
11:45:25 AM:   Error message
11:45:25 AM:   Command failed with exit code 1: yarn build
11:45:25 AM: ​
11:45:25 AM:   Error location
11:45:25 AM:   In Build command from Netlify app:
11:45:25 AM:   yarn build
11:45:25 AM: ​
11:45:25 AM:   Resolved config
11:45:25 AM:   build:
11:45:25 AM:     command: yarn build
11:45:25 AM:     commandOrigin: ui
11:45:25 AM:     publish: /opt/build/repo/out
11:45:25 AM:   plugins:
11:45:25 AM:     - inputs: {}
11:45:25 AM:       origin: ui
11:45:25 AM:       package: '@netlify/plugin-nextjs'
11:45:26 AM: Caching artifacts
11:45:26 AM: Started saving node modules
11:45:26 AM: Finished saving node modules
11:45:26 AM: Started saving build plugins
11:45:26 AM: Finished saving build plugins
11:45:26 AM: Started saving yarn cache
11:45:26 AM: Finished saving yarn cache
11:45:26 AM: Started saving pip cache
11:45:26 AM: Finished saving pip cache
11:45:26 AM: Started saving emacs cask dependencies
11:45:26 AM: Finished saving emacs cask dependencies
11:45:26 AM: Started saving maven dependencies
11:45:26 AM: Finished saving maven dependencies
11:45:26 AM: Started saving boot dependencies
11:45:26 AM: Finished saving boot dependencies
11:45:26 AM: Started saving rust rustup cache
11:45:26 AM: Finished saving rust rustup cache
11:45:26 AM: Started saving go dependencies
11:45:26 AM: Finished saving go dependencies
11:45:26 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:45:26 AM: Creating deploy upload records
11:45:26 AM: Failing build: Failed to build site
11:45:26 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
11:45:26 AM: Finished processing build request in 1m45.477997638s

Well like an idiot I have the components/Head.tsx file capitalized locally but somehow not in my GitHub repo.

1 Like

Hey there, @onboardlist :wave:

Thank you so much for circling back and updating this thread with your solution. We appreciate it :netliconfetti:

1 Like