Next.js application deploy does not succeed

I tried to deploy the Next.js app, but it fails. It works fine in my local environment. Here is the source code: GitHub - yutakobayashidev/timeline: yutakobayashi's timeline

3:21:07 PM: Build ready to start
3:21:09 PM: build-image version: 081db65c3e4ce8423fedb40e7689a87de6f84667
3:21:09 PM: build-image tag: v4.3.1
3:21:09 PM: buildbot version: f650485c830eb31597911322420b99299a4303b8
3:21:09 PM: Building without cache
3:21:09 PM: Starting to prepare the repo for build
3:21:09 PM: No cached dependencies found. Cloning fresh repo
3:21:09 PM: git clone https://github.com/yutakobayashidev/timeline
3:21:10 PM: Preparing Git Reference refs/heads/main
3:21:10 PM: Parsing package.json dependencies
3:21:11 PM: Starting build script
3:21:11 PM: Installing dependencies
3:21:11 PM: Python version set to 2.7
3:21:12 PM: Downloading and installing node v16.10.0...
3:21:12 PM: Downloading https://nodejs.org/dist/v16.10.0/node-v16.10.0-linux-x64.tar.xz...
3:21:12 PM: Computing checksum with sha256sum
3:21:12 PM: Checksums matched!
3:21:16 PM: Now using node v16.10.0 (npm v7.24.0)
3:21:16 PM: Started restoring cached build plugins
3:21:16 PM: Finished restoring cached build plugins
3:21:16 PM: Attempting ruby version 2.7.2, read from environment
3:21:18 PM: Using ruby version 2.7.2
3:21:18 PM: Using PHP version 8.0
3:21:18 PM: Started restoring cached node modules
3:21:18 PM: Finished restoring cached node modules
3:21:18 PM: Installing NPM modules using NPM version 7.24.0
3:21:20 PM: npm WARN old lockfile
3:21:20 PM: npm WARN old lockfile The package-lock.json file was created with an old version of npm,
3:21:20 PM: npm WARN old lockfile so supplemental metadata must be fetched from the registry.
3:21:20 PM: npm WARN old lockfile
3:21:20 PM: npm WARN old lockfile This is a one-time fix-up, please be patient...
3:21:20 PM: npm WARN old lockfile
3:21:30 PM: npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
3:21:33 PM: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
3:21:38 PM: added 476 packages, and audited 477 packages in 19s
3:21:38 PM: 63 packages are looking for funding
3:21:38 PM:   run `npm fund` for details
3:21:38 PM: 6 moderate severity vulnerabilities
3:21:38 PM: To address issues that do not require attention, run:
3:21:38 PM:   npm audit fix
3:21:38 PM: To address all issues (including breaking changes), run:
3:21:38 PM:   npm audit fix --force
3:21:38 PM: Run `npm audit` for details.
3:21:38 PM: NPM modules installed
3:21:38 PM: Started restoring cached go cache
3:21:38 PM: Finished restoring cached go cache
3:21:38 PM: go version go1.16.5 linux/amd64
3:21:38 PM: go version go1.16.5 linux/amd64
3:21:38 PM: Installing missing commands
3:21:38 PM: Verify run directory
3:21:40 PM: ​
3:21:40 PM: ────────────────────────────────────────────────────────────────
3:21:40 PM:   Netlify Build                                                 
3:21:40 PM: ────────────────────────────────────────────────────────────────
3:21:40 PM: ​
3:21:40 PM: ❯ Version
3:21:40 PM:   @netlify/build 18.13.1
3:21:40 PM: ​
3:21:40 PM: ❯ Flags
3:21:40 PM:   baseRelDir: true
3:21:40 PM:   buildId: 6150115379d2cf019ead8c65
3:21:40 PM:   deployId: 6150115379d2cf019ead8c67
3:21:40 PM: ​
3:21:40 PM: ❯ Current directory
3:21:40 PM:   /opt/build/repo
3:21:40 PM: ​
3:21:40 PM: ❯ Config file
3:21:40 PM:   No config file was defined: using default values.
3:21:40 PM: ​
3:21:40 PM: ❯ Context
3:21:40 PM:   production
3:21:40 PM: ​
3:21:40 PM: ❯ Installing plugins
3:21:40 PM:    - @netlify/plugin-nextjs@3.9.0
3:21:49 PM: ​
3:21:49 PM: ❯ Loading plugins
3:21:49 PM:    - @netlify/plugin-nextjs@3.9.0 from Netlify app
3:21:50 PM: ​
3:21:50 PM: ────────────────────────────────────────────────────────────────
3:21:50 PM:   1. onPreBuild command from @netlify/plugin-nextjs             
3:21:50 PM: ────────────────────────────────────────────────────────────────
3:21:50 PM: ​
3:21:50 PM: Using Next.js 10.0.8
3:21:51 PM: The "target" config property must be one of "serverless", "experimental-serverless-trace". Building with "serverless" target.
3:21:51 PM: No Next.js cache to restore.
3:21:51 PM: ​
3:21:51 PM: (@netlify/plugin-nextjs onPreBuild completed in 1.3s)
3:21:51 PM: ​
3:21:51 PM: ────────────────────────────────────────────────────────────────
3:21:51 PM:   2. Build command from Netlify app                             
3:21:51 PM: ────────────────────────────────────────────────────────────────
3:21:51 PM: ​
3:21:51 PM: $ npm run build
3:21:52 PM: > timeline@0.1.0 build
3:21:52 PM: > run-s build:items build:next
3:21:52 PM: > timeline@0.1.0 build:items
3:21:52 PM: > ts-node --project tsconfig.builder.json ./src/json-builder.ts
3:21:55 PM: env "SHEET_ID", "GOOGLE_SERVICE_ACCOUNT_EMAIL", "GOOGLE_PRIVATE_KEY" are required.
3:21:55 PM: ERROR: "build:items" exited with 1.
3:21:56 PM: ​
3:21:56 PM: ────────────────────────────────────────────────────────────────
3:21:56 PM:   "build.command" failed                                        
3:21:56 PM: ────────────────────────────────────────────────────────────────
3:21:56 PM: ​
3:21:56 PM:   Error message
3:21:56 PM:   Command failed with exit code 1: npm run build
3:21:56 PM: ​
3:21:56 PM:   Error location
3:21:56 PM:   In Build command from Netlify app:
3:21:56 PM:   npm run build
3:21:56 PM: ​
3:21:56 PM:   Resolved config
3:21:56 PM:   build:
3:21:56 PM:     command: npm run build
3:21:56 PM:     commandOrigin: ui
3:21:56 PM:     publish: /opt/build/repo/out
3:21:56 PM:     publishOrigin: ui
3:21:56 PM:   plugins:
3:21:56 PM:     - inputs: {}
3:21:56 PM:       origin: ui
3:21:56 PM:       package: '@netlify/plugin-nextjs'
3:21:56 PM: Caching artifacts
3:21:56 PM: Started saving node modules
3:21:56 PM: Finished saving node modules
3:21:56 PM: Started saving build plugins
3:21:56 PM: Finished saving build plugins
3:21:56 PM: Started saving pip cache
3:21:56 PM: Finished saving pip cache
3:21:56 PM: Started saving emacs cask dependencies
3:21:56 PM: Finished saving emacs cask dependencies
3:21:56 PM: Started saving maven dependencies
3:21:56 PM: Finished saving maven dependencies
3:21:56 PM: Started saving boot dependencies
3:21:56 PM: Finished saving boot dependencies
3:21:56 PM: Started saving rust rustup cache
3:21:56 PM: Finished saving rust rustup cache
3:21:56 PM: Started saving go dependencies
3:21:56 PM: Finished saving go dependencies
3:21:59 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:21:59 PM: Creating deploy upload records
3:21:59 PM: Failing build: Failed to build site
3:21:59 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
3:21:59 PM: Finished processing build request in 50.171986593s

Hi @yutakobayashi

Have you created these environment variables?

Thank you for your answer. You were right! Problem solved.