This took me a few hours to solve. The issue is that Vite by default doesn't polyfill. This leads to errors with the util package.
Errors
Uncaught TypeError: Cannot read properties of undefined (reading 'custom')

Solution
npm i util
vite.config.js
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
util: "util/",
},
},
define: {
"process.env": { NODE_ENV: "development" }, // util expects a process.env
},
});
Maybe instead of util.inspect you could just use JSON.stringify. Otherwise, this might be helpful to include in the docs or mention this somewhere.
This took me a few hours to solve. The issue is that Vite by default doesn't polyfill. This leads to errors with the util package.
Errors
Uncaught TypeError: Cannot read properties of undefined (reading 'custom')

Solution
npm i utilvite.config.js
Maybe instead of util.inspect you could just use JSON.stringify. Otherwise, this might be helpful to include in the docs or mention this somewhere.