vite-express: production build on Netlify keeps failing

Hi, I’m setting up vite-express for the first time. This is what the script block in my package.json looks like:

  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview"
  },

And, here’s my server file.

import express from "express";
import ViteExpress from "vite-express";

export const app = express();

ViteExpress.config({
 mode: "production",
});

ViteExpress.listen(app, 5173, () => console.log("Server is listening..."));

In my build logs, I keep getting “tsc: not found”. Whenever I go ahead remove tsc from the command in package.json, and I’d get vite: not found.

What could be wrong? For context; here’s an excerpt of what the error looks like:

7:51:22 PM: Build command from Netlify app                                
7:51:22 PM: ────────────────────────────────────────────────────────────────
7:51:22 PM: ​
7:51:22 PM: $ pnpm build
7:51:22 PM: > app@0.0.0 build /opt/build/repo
7:51:22 PM: > vite build
7:51:22 PM: sh: 1: vite: not found
7:51:22 PM:  ELIFECYCLE  Command failed.
7:51:22 PM: ​
7:51:22 PM: "build.command" failed                                        
7:51:22 PM: ────────────────────────────────────────────────────────────────
7:51:22 PM: ​
7:51:22 PM:   Error message
7:51:22 PM:   Command failed with exit code 1: pnpm build (https://ntl.fyi/exit-code-1)
7:51:22 PM: ​
7:51:22 PM:   Error location
7:51:22 PM:   In Build command from Netlify app:
7:51:22 PM:   pnpm build

About this issue

  • Original URL
  • State: closed
  • Created 4 months ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

I couldn’t figure out why. Eventually I moved to Next.js.

Thanks for your help @szymmis