Vite created with react-ts template fail to build

PLEASE help us help you by writing a good post!

  • We need to know your netlify site name. Example: gifted-antelope-58b104.netlify.app
  • DNS issues? Tell us the custom domain, tell us the error message! We can’t help if we don’t know your domain.
  • Build problems? Link or paste the FULL build log & build settings screenshot
  • Did you try Ask Netlify, our generative AI chatbot, before posting? It pulls info from Support Guides and recent solved forums posts.

The better the post - the faster the answer.

site name: gemproweb

DNS issues? No

Build problems? Yes.
build log:
9:48:21 PM: Waiting for other deploys from your team to complete. Check the queue: Netlify
9:49:13 PM: build-image version: 305a433542175847ae19d9789b7bf59fd8b9de02 (noble)
9:49:13 PM: buildbot version: 305a433542175847ae19d9789b7bf59fd8b9de02
9:49:14 PM: Fetching cached dependencies
9:49:14 PM: Failed to fetch cache, continuing with build
9:49:14 PM: Starting to prepare the repo for build
9:49:14 PM: No cached dependencies found. Cloning fresh repo
9:49:14 PM: git clone --filter=blob:none git@github.com:xzwang2005/meg
9:49:15 PM: Preparing Git Reference refs/heads/main
9:49:16 PM: Custom build command detected. Proceeding with the specified command: ‘cd meg && npm run build’
9:49:17 PM: Starting to install dependencies
9:49:17 PM: Python version set to 3.13.3
9:49:18 PM: Ruby version set to 2.7.2
9:49:18 PM: mise go@1.19 install
9:49:18 PM: mise go@1.19 download go1.19.linux-amd64.tar.gz
9:49:20 PM: mise go@1.19 checksum go1.19.linux-amd64.tar.gz
9:49:20 PM: mise go@1.19 extract go1.19.linux-amd64.tar.gz
9:49:22 PM: mise go@1.19 go version
9:49:22 PM: mise go@1.19 go version go1.19 linux/amd64
9:49:23 PM: mise go@1.19 ✓ installed
9:49:23 PM: Go version set to 1.19
9:49:23 PM: Using PHP version 8.3
9:49:25 PM: v22.14.0 is already installed.
9:49:25 PM: Now using node v22.14.0 (npm v10.9.2)
9:49:25 PM: Enabling Node.js Corepack
9:49:25 PM: Started restoring cached build plugins
9:49:25 PM: Finished restoring cached build plugins
9:49:26 PM: Successfully installed dependencies
9:49:26 PM: Starting build script
9:49:27 PM: Detected 0 framework(s)
9:49:27 PM: Section completed: initializing
9:49:29 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
9:49:29 PM: ​
9:49:29 PM: Netlify Build
9:49:29 PM: ────────────────────────────────────────────────────────────────
9:49:29 PM: ​
9:49:29 PM: ❯ Version
9:49:29 PM: @netlify/build 32.0.0
9:49:29 PM: ​
9:49:29 PM: ❯ Flags
9:49:29 PM: accountId: 67fdd9aa74f67e9ae4935df9
9:49:29 PM: baseRelDir: true
9:49:29 PM: buildId: 67fde5158663770008483896
9:49:29 PM: deployId: 67fde5158663770008483898
9:49:29 PM: ​
9:49:29 PM: ❯ Current directory
9:49:29 PM: /opt/build/repo
9:49:29 PM: ​
9:49:29 PM: ❯ Config file
9:49:29 PM: /opt/build/repo/netlify.toml
9:49:29 PM: ​
9:49:29 PM: ❯ Context
9:49:29 PM: production
9:49:29 PM: ​
9:49:29 PM: build.command from netlify.toml
9:49:29 PM: ────────────────────────────────────────────────────────────────
9:49:29 PM: ​
9:49:29 PM: $ cd meg && npm run build
9:49:29 PM: > meg@0.0.0 build
9:49:29 PM: > tsc -b && vite build
9:49:29 PM: sh: 1: tsc: not found
9:49:29 PM: ​
9:49:29 PM: “build.command” failed
9:49:29 PM: ────────────────────────────────────────────────────────────────
9:49:29 PM: ​
9:49:29 PM: Error message
9:49:29 PM: Command failed with exit code 127: cd meg && npm run build (Search results for '"non-zero exit code: 127"' - Netlify Support Forums)
9:49:29 PM: ​
9:49:29 PM: Error location
9:49:29 PM: In build.command from netlify.toml:
9:49:29 PM: cd meg && npm run build
9:49:29 PM: ​
9:49:29 PM: Resolved config
9:49:29 PM: build:
9:49:29 PM: command: cd meg && npm run build
9:49:29 PM: commandOrigin: config
9:49:29 PM: publish: /opt/build/repo/meg/dist
9:49:29 PM: publishOrigin: config
9:49:29 PM: functionsDirectory: /opt/build/repo/netlify/functions
9:49:29 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:49:29 PM: Failing build: Failed to build site
9:49:30 PM: Finished processing build request in 16.192s

Build settings
Runtime: Not set
Base directory: /
Package directory: Not set
Build command: cd meg && tsc -b && npm run build
Publish directory: ./meg/dist
Functions directory: netlify/functions
Build status: Active

Code structure:

tsc -b in the build command was added later since the error was that tsc not found. But that didn’t help. When I run npm run build locally, it invokes tsc -b automatically.

I’ve also added ts as dependency in the package.json

Hi @xzwang2005,

Thanks for reaching out and welcome to Netlify’s Support Forums!

Could you make sure typescript is listed in meg/package.json, not just the root if you’re using a monorepo?

Thanks. Problem solved after I re-organized the folder and move all vite created files to the root.

1 Like