Minimal reproduction of a Vite bug where defining 2+ non-client environments in vitest.config.ts causes a require is not defined error. Vite's mergeConfig shares nested object references across environments, so when Vitest's configEnvironment hook mutates resolve.noExternal for one environment, it leaks to others — causing jsdom (CJS) to be inlined into an ESM-only evaluator.
npm cinpm testYou should see ReferenceError: require is not defined. Removing one of the two environments from vitest.config.ts makes the error go away. So does uncommenting the resolve: {} block, which prevents the mutation from happening in the first place.