TypeError: Failed to resolve module specifier "h3" after successful build for node-server preset

My app is able to build with npm run build, but my app is mostly not working once I run it. I see the following error in my console:
localhost/:1 Uncaught (in promise) TypeError: Failed to resolve module specifier "h3". Relative references must start with either "/", "./", or "../".

Since h3 is a dependency of Tanstack Start, I wanted to check here first to see if there is a potential issue with my build setup. Below is my app config:
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "@tanstack/react-start/config";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import tsConfigPaths from "vite-tsconfig-paths";

export default defineConfig({
  vite: {
    plugins: [
      nodePolyfills({
        include: ["stream", "buffer", "process", "util"],
        globals: {
          Buffer: true,
          global: true,
          process: true,
        },
      }),
      tsConfigPaths({
        projects: ["./tsconfig.json"],
      }),
      tailwindcss(),
    ],
    resolve: {
      alias: {
        stream: "stream-browserify",
        h3: "/node_modules/h3/dist/index.mjs",
      },
    },
    optimizeDeps: {
      include: ["h3"],
    },
    build: {
      rollupOptions: {
        external: [/^node:.*/],
        output: {
          globals: {
            stream: "stream-browserify",
          },
        },
      },
    },
  },
  server: {
    preset: "node-server",
  }
});
Was this page helpful?