Deploy failed on React.js + Vite.js site due to typescript errors i don't get locally

  • netlify site name: chipper-choux-5a1391.netlify.app
  • Deploy log:
3:39:53 PM: build-image version: 68a2c262fa3c95a08a1716b8dde8fba0e332ec73 (focal)
3:39:53 PM: buildbot version: 68a2c262fa3c95a08a1716b8dde8fba0e332ec73
3:39:54 PM: Fetching cached dependencies
3:39:54 PM: Failed to fetch cache, continuing with build
3:39:54 PM: Starting to prepare the repo for build
3:39:54 PM: No cached dependencies found. Cloning fresh repo
3:39:54 PM: git clone --filter=blob:none https://github.com/Alex070822/frontend-mentor
3:39:54 PM: Preparing Git Reference refs/heads/main
3:39:55 PM: Parsing package.json dependencies
3:39:56 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'ip-address-tracker/dist' versus 'dist' in the Netlify UI
3:39:56 PM: Starting to install dependencies
3:39:56 PM: Python version set to 3.8
3:39:56 PM: Attempting Ruby version 2.7.2, read from environment
3:39:57 PM: Using Ruby version 2.7.2
3:39:57 PM: Started restoring cached go cache
3:39:57 PM: Finished restoring cached go cache
3:39:57 PM: Installing Go version 1.19.5 (requested 1.19.5)
3:40:02 PM: go version go1.19.5 linux/amd64
3:40:03 PM: Using PHP version 8.0
3:40:04 PM: v16.20.0 is already installed.
3:40:04 PM: Now using node v16.20.0 (npm v8.19.4)
3:40:04 PM: Enabling Node.js Corepack
3:40:04 PM: Started restoring cached build plugins
3:40:04 PM: Finished restoring cached build plugins
3:40:04 PM: Started restoring cached corepack dependencies
3:40:04 PM: Finished restoring cached corepack dependencies
3:40:04 PM: No npm workspaces detected
3:40:04 PM: Started restoring cached node modules
3:40:04 PM: Finished restoring cached node modules
3:40:05 PM: Installing npm packages using npm version 8.19.4
3:40:07 PM: added 123 packages, and audited 124 packages in 2s
3:40:07 PM: 13 packages are looking for funding
3:40:07 PM:   run `npm fund` for details
3:40:07 PM: found 0 vulnerabilities
3:40:07 PM: npm packages installed
3:40:07 PM: Install dependencies script success
3:40:07 PM: Starting build script
3:40:08 PM: Detected 1 framework(s)
3:40:08 PM: "vite" at version "4.2.1"
3:40:08 PM: Section completed: initializing
3:40:10 PM: ​
3:40:10 PM:   Netlify Build                                                 
3:40:10 PM: ────────────────────────────────────────────────────────────────
3:40:10 PM: ​
3:40:10 PM: ❯ Version
3:40:10 PM:   @netlify/build 29.9.2
3:40:10 PM: ​
3:40:10 PM: ❯ Flags
3:40:10 PM:   baseRelDir: true
3:40:10 PM:   buildId: 644302a6bf985c00c72abda8
3:40:10 PM:   deployId: 644302a6bf985c00c72abdaa
3:40:10 PM: ​
3:40:10 PM: ❯ Current directory
3:40:10 PM:   /opt/build/repo/ip-address-tracker
3:40:10 PM: ​
3:40:10 PM: ❯ Config file
3:40:10 PM:   No config file was defined: using default values.
3:40:10 PM: ​
3:40:10 PM: ❯ Context
3:40:10 PM:   production
3:40:10 PM: ​
3:40:10 PM:   1. Build command from Netlify app                             
3:40:10 PM: ────────────────────────────────────────────────────────────────
3:40:10 PM: ​
3:40:10 PM: $ npm run build
3:40:10 PM: > ip-address-tracker@0.0.0 build
3:40:10 PM: > tsc && vite build
3:40:11 PM: src/App.tsx(116,13): error TS2322: Type 'string' is not assignable to type 'number'.
3:40:11 PM: src/App.tsx(117,13): error TS2322: Type 'string' is not assignable to type 'number'.
3:40:11 PM: src/App.tsx(118,13): error TS2322: Type 'string' is not assignable to type 'number'.
3:40:11 PM: src/components/MapView/MapView.tsx(41,11): error TS2339: Property 'flyTo' does not exist on type 'never'.
3:40:11 PM: src/components/MapView/MapView.tsx(54,9): error TS2322: Type 'number[]' is not assignable to type 'LatLngExpression | undefined'.
3:40:11 PM:   Type 'number[]' is not assignable to type 'LatLngTuple'.
3:40:11 PM:     Target requires 2 element(s) but source may have fewer.
3:40:11 PM: src/components/MapView/MapView.tsx(65,17): error TS2322: Type 'number[]' is not assignable to type 'LatLngExpression'.
3:40:11 PM:   Type 'number[]' is not assignable to type 'LatLngTuple'.
3:40:11 PM: ​
3:40:11 PM:   "build.command" failed                                        
3:40:11 PM: ────────────────────────────────────────────────────────────────
3:40:11 PM: ​
3:40:11 PM:   Error message
3:40:11 PM:   Command failed with exit code 2: npm run build (https://ntl.fyi/exit-code-2)
3:40:11 PM: ​
3:40:11 PM:   Error location
3:40:11 PM:   In Build command from Netlify app:
3:40:11 PM:   npm run build
3:40:11 PM: ​
3:40:11 PM:   Resolved config
3:40:11 PM:   build:
3:40:11 PM:     base: /opt/build/repo/ip-address-tracker
3:40:11 PM:     command: npm run build
3:40:11 PM:     commandOrigin: ui
3:40:11 PM:     publish: /opt/build/repo/ip-address-tracker/dist
3:40:11 PM:     publishOrigin: ui
3:40:12 PM: Caching artifacts
3:40:12 PM: Started saving node modules
3:40:12 PM: Finished saving node modules
3:40:12 PM: Started saving build plugins
3:40:12 PM: Finished saving build plugins
3:40:12 PM: Started saving corepack cache
3:40:13 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
3:40:12 PM: Finished saving corepack cache
3:40:12 PM: Started saving pip cache
3:40:12 PM: Finished saving pip cache
3:40:12 PM: Started saving emacs cask dependencies
3:40:12 PM: Finished saving emacs cask dependencies
3:40:12 PM: Started saving maven dependencies
3:40:12 PM: Finished saving maven dependencies
3:40:12 PM: Started saving boot dependencies
3:40:12 PM: Finished saving boot dependencies
3:40:12 PM: Started saving rust rustup cache
3:40:12 PM: Finished saving rust rustup cache
3:40:12 PM: Started saving go dependencies
3:40:12 PM: Finished saving go dependencies
3:40:12 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:40:13 PM: Failing build: Failed to build site
3:40:13 PM: Finished processing build request in 19.451s

This doesn’t look like a Netlify issue. I get the same errors locally:

You’re probably not running npm run build locally, which is why you don’t see the errors.

you were right, i was using npm run dev locally so i couldn’t see the typescript errors

Thanks for sharing this with the community! Good luck. (: