Type 'string | undefined' is not assignable to type 'string'

Hi everyone, I have the following error log and other details about one of my Github repositories I am trying to deploy. Please help me out with fixing the issue. Thank you

Netlify Site Name: https://kaleidoscopic-crisp-8506b3.netlify.app

Netlfiy Settings:

Build Log:

3:22:22 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
3:21:11 AM: build-image version: c11c0eb9939c949586b0f78302107908b668a11e (focal)
3:21:11 AM: buildbot version: 55489dea6ef0428412532c40d27c9bef94a7fd4a
3:21:11 AM: Fetching cached dependencies
3:21:11 AM: Failed to fetch cache, continuing with build
3:21:11 AM: Starting to prepare the repo for build
3:21:11 AM: No cached dependencies found. Cloning fresh repo
3:21:11 AM: git clone --filter=blob:none https://github.com/wasim-ullah/blog
3:21:12 AM: Preparing Git Reference refs/heads/main
3:21:14 AM: Starting to install dependencies
3:21:14 AM: Python version set to 3.8
3:21:14 AM: Attempting Ruby version 2.7.2, read from environment
3:21:14 AM: Using Ruby version 2.7.2
3:21:15 AM: Started restoring cached go cache
3:21:15 AM: Finished restoring cached go cache
3:21:16 AM: go version go1.19.10 linux/amd64
3:21:16 AM: Using PHP version 8.0
3:21:17 AM: Downloading and installing node v18.16.1...
3:21:17 AM: Downloading https://nodejs.org/dist/v18.16.1/node-v18.16.1-linux-x64.tar.xz...
3:21:18 AM: Computing checksum with sha256sum
3:21:18 AM: Checksums matched!
3:21:20 AM: Now using node v18.16.1 (npm v9.5.1)
3:21:20 AM: Enabling Node.js Corepack
3:21:20 AM: Started restoring cached build plugins
3:21:20 AM: Finished restoring cached build plugins
3:21:20 AM: Started restoring cached corepack dependencies
3:21:20 AM: Finished restoring cached corepack dependencies
3:21:21 AM: Found pnpm version (7.13.4) that doesn't match expected ()
Usage Error: Invalid package manager specification in CLI arguments; expected a semver version, range, or tag
3:21:21 AM: $ corepack prepare [--activate] [--all] [--json] [-o,--output] ...
3:21:21 AM: No pnpm workspaces detected
3:21:21 AM: Started restoring cached node modules
3:21:21 AM: Finished restoring cached node modules
3:21:21 AM: Installing npm packages using pnpm version 7.13.4
3:21:21 AM:  WARN  Ignoring not compatible lockfile at /opt/build/repo/pnpm-lock.yaml
3:21:21 AM: Progress: resolved 1, reused 0, downloaded 0, added 0
3:21:22 AM: Progress: resolved 29, reused 0, downloaded 18, added 0
3:21:23 AM: Progress: resolved 73, reused 0, downloaded 54, added 0
3:21:24 AM: Progress: resolved 131, reused 0, downloaded 102, added 0
3:21:25 AM: Progress: resolved 199, reused 0, downloaded 165, added 0
3:21:26 AM: Progress: resolved 298, reused 0, downloaded 258, added 0
3:21:27 AM: Packages: +378
3:21:27 AM: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3:21:27 AM: Progress: resolved 386, reused 0, downloaded 351, added 0
3:21:27 AM: Packages are hard linked from the content-addressable store to the virtual store.
3:21:27 AM:   Content-addressable store is at: /opt/build/.pnpm-store/v3
3:21:27 AM:   Virtual store is at:             node_modules/.pnpm
3:21:28 AM: Progress: resolved 386, reused 0, downloaded 374, added 374
3:21:29 AM: Progress: resolved 386, reused 0, downloaded 376, added 376
3:21:30 AM: Progress: resolved 386, reused 0, downloaded 378, added 378, done
3:21:30 AM: dependencies:
3:21:30 AM: + @fontsource/inter 4.5.15 (5.0.3 is available)
3:21:30 AM: + @fontsource/roboto-mono 4.5.10 (5.0.3 is available)
3:21:30 AM: + @mdx-js/react 2.3.0
3:21:30 AM: + @next/mdx 13.1.7-canary.10 (13.4.7 is available)
3:21:30 AM: + @types/node-fetch 2.6.4
3:21:30 AM: + @upstash/redis 1.22.0
3:21:30 AM: + @vercel/analytics 1.0.1
3:21:30 AM: + comma-number 2.1.0
3:21:30 AM: + date-fns 2.30.0
3:21:30 AM: + image-size 1.0.2
3:21:30 AM: + load-script 1.0.0 (2.0.0 is available)
3:21:30 AM: + next 13.3.2-canary.13 (13.4.7 is available)
3:21:30 AM: + react 18.2.0
3:21:30 AM: + react-dom 18.2.0
3:21:30 AM: + react-intersection-observer 8.34.0 (9.5.2 is available)
3:21:30 AM: + react-tweet 2.0.2
3:21:30 AM: + react-wrap-balancer 0.2.4 (1.0.0 is available)
3:21:30 AM: + react-youtube 10.1.0
3:21:30 AM: + swr 2.2.0
3:21:30 AM: + time-ago 0.2.1
3:21:30 AM: devDependencies:
3:21:30 AM: + @types/comma-number 2.1.0
3:21:30 AM: + @types/react 18.2.14
3:21:30 AM: + @types/react-dom 18.2.6
3:21:30 AM: + autoprefixer 10.4.14
3:21:30 AM: + eslint 8.43.0
3:21:30 AM: + eslint-config-next 13.4.7
3:21:30 AM: + postcss 8.4.24
3:21:30 AM: + prettier 2.8.8
3:21:30 AM: + tailwindcss 3.3.2
3:21:30 AM: + typescript 4.9.5 (5.1.6 is available)
3:21:30 AM: Done in 9.6s
3:21:30 AM: npm packages installed using pnpm
3:21:31 AM: Install dependencies script success
3:21:31 AM: Starting build script
3:21:32 AM: Detected 1 framework(s)
3:21:32 AM: next at version 13.3.2-canary.13
3:21:32 AM: Section completed: initializing
3:21:33 AM: ​
3:21:33 AM: Netlify Build                                                 
3:21:33 AM: ────────────────────────────────────────────────────────────────
3:21:33 AM: ​
3:21:33 AM: ❯ Version
3:21:33 AM:   @netlify/build 29.12.1
3:21:33 AM: ​
3:21:33 AM: ❯ Flags
3:21:33 AM:   baseRelDir: true
3:21:33 AM:   buildId: 649e1febe155e60ec51430ce
3:21:33 AM:   deployId: 649e1febe155e60ec51430d0
3:21:33 AM:   tracing:
3:21:33 AM:     enabled: 'false'
3:21:33 AM:     host: 10.65.139.53
3:21:33 AM:     parentSpanId: fffb2eee84ad15f0
3:21:33 AM:     traceFlags: '00'
3:21:33 AM:     traceId: 011034d524240c7886d57f628036041d
3:21:33 AM: ​
3:21:33 AM: ❯ Current directory
3:21:33 AM:   /opt/build/repo
3:21:33 AM: ​
3:21:33 AM: ❯ Config file
3:21:33 AM:   No config file was defined: using default values.
3:21:33 AM: ​
3:21:33 AM: ❯ Context
3:21:33 AM:   production
3:21:33 AM: ​
3:21:33 AM: ❯ Installing plugins
3:21:33 AM:    - @netlify/plugin-nextjs@4.38.1
3:21:45 AM: ​
3:21:45 AM: ❯ Using Next.js Runtime - v4.38.1
3:21:46 AM: ​
3:21:46 AM: @netlify/plugin-nextjs (onPreBuild event)                     
3:21:46 AM: ────────────────────────────────────────────────────────────────
3:21:46 AM: ​
3:21:46 AM: No Next.js cache to restore.
3:21:46 AM: Netlify configuration property build.environment.NEXT_PRIVATE_TARGET value changed.
3:21:46 AM: ​
3:21:46 AM: (@netlify/plugin-nextjs onPreBuild completed in 13ms)
3:21:46 AM: ​
3:21:46 AM: Build command from Netlify app                                
3:21:46 AM: ────────────────────────────────────────────────────────────────
3:21:46 AM: ​
3:21:46 AM: $ npm run build
3:21:47 AM: > build
3:21:47 AM: > next build
3:21:47 AM: warn  - You have enabled experimental features (appDir, mdxRs) in next.config.js.
3:21:47 AM: warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
3:21:47 AM: info  - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback
3:21:47 AM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
3:21:47 AM: info  - Creating an optimized production build...
3:21:58 AM: Warning: For production Image Optimization with Next.js, the optional 'sharp' package is strongly recommended. Run 'yarn add sharp', and Next.js will use it automatically for Image Optimization.
3:21:58 AM: Read more: https://nextjs.org/docs/messages/sharp-missing-in-production
3:22:18 AM: info  - Compiled successfully
3:22:18 AM: info  - Linting and checking validity of types...
3:22:19 AM: The prop value with an expression type of AwaitExpression could not be resolved. Please file an issue ( https://github.com/jsx-eslint/jsx-ast-utils/issues/new ) to get this fixed immediately.
3:22:20 AM: Failed to compile.
3:22:20 AM: 
3:22:20 AM: ./app/redis.ts:3:15
3:22:20 AM: Type error: No overload matches this call.
3:22:20 AM:   Overload 1 of 2, '(config: RedisConfigNodejs): Redis', gave the following error.
3:22:20 AM:     Type 'string | undefined' is not assignable to type 'string'.
3:22:20 AM:       Type 'undefined' is not assignable to type 'string'.
3:22:20 AM:   Overload 2 of 2, '(requesters: Requester): Redis', gave the following error.
3:22:20 AM:     Argument of type '{ url: string; token: string | undefined; }' is not assignable to parameter of type 'Requester'.
3:22:20 AM:       Object literal may only specify known properties, and 'url' does not exist in type 'Requester'.
3:22:20 AM:   1 | import { Redis } from @upstash/redis;
3:22:20 AM:   2 | 
3:22:20 AM: > 3 | const redis = new Redis({
3:22:20 AM:     |               ^
3:22:20 AM:   4 |   url: https://global-apt-bear-30602.upstash.io,
3:22:20 AM:   5 |   token: process.env.UPSTASH_REDIS_REST_TOKEN,
3:22:20 AM:   6 | });
3:22:20 AM: ​
3:22:20 AM: build.command failed                                        
3:22:20 AM: ────────────────────────────────────────────────────────────────
3:22:20 AM: ​
3:22:20 AM:   Error message
3:22:20 AM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
3:22:20 AM: ​
3:22:20 AM:   Error location
3:22:20 AM:   In Build command from Netlify app:
3:22:20 AM:   npm run build
3:22:20 AM: ​
3:22:20 AM:   Resolved config
3:22:20 AM:   build:
3:22:20 AM:     command: npm run build
3:22:20 AM:     commandOrigin: ui
3:22:20 AM:     environment:
3:22:20 AM:       - NEXT_PRIVATE_TARGET
3:22:20 AM:     publish: /opt/build/repo/.next
3:22:20 AM:     publishOrigin: ui
3:22:20 AM:   plugins:
3:22:20 AM:     - inputs: {}
3:22:20 AM:       origin: ui
3:22:20 AM:       package: '@netlify/plugin-nextjs'
3:22:21 AM: Caching artifacts
3:22:21 AM: Started saving node modules
3:22:21 AM: Finished saving node modules
3:22:21 AM: Started saving build plugins
3:22:21 AM: Finished saving build plugins
3:22:21 AM: Started saving corepack cache
3:22:21 AM: Finished saving corepack cache
3:22:21 AM: Started saving pip cache
3:22:21 AM: Finished saving pip cache
3:22:21 AM: Started saving emacs cask dependencies
3:22:21 AM: Finished saving emacs cask dependencies
3:22:21 AM: Started saving maven dependencies
3:22:21 AM: Finished saving maven dependencies
3:22:21 AM: Started saving boot dependencies
3:22:21 AM: Finished saving boot dependencies
3:22:21 AM: Started saving rust rustup cache
3:22:21 AM: Finished saving rust rustup cache
3:22:21 AM: Started saving go dependencies
3:22:21 AM: Finished saving go dependencies
3:22:22 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:22:22 AM: Failing build: Failed to build site
3:22:23 AM: Finished processing build request in 1m11.547s

I would highly appreciate your directions.

Appears to be some issue with your code and Type definitions. Not something we can help debug.

First error says you’re trying to assign undefined to string and the second one says, url is not an expected property.