Upgrade to Vite 7 on Node 22
Pick a supported Node version for Vite 7, remove obsolete config options, and check the new browser build target.
You bump vite from 6 to 7, start the dev server, and it dies with TypeError: crypto.hash is not a function. On another machine it starts but prints a warning about your Node version. Both come from the same change: Vite 7 raised its Node floor.
If your destination is Vite 8, fix the Vite 7 changes first so failures are easier to isolate.
The Node range, and what a miss looks like
Vite 7 requires Node 20.19+ or 22.12+. In those releases require() can load an ES module without a flag, which lets Vite 7 ship as ESM only.
$ node --version
v18.20.8
$ npx vite
You are using Node.js 18.20.8. Vite requires Node.js version 20.19+ or 22.12+. Please upgrade your Node.js version.
error when starting dev server:
TypeError: crypto.hash is not a function
$ node --version
v20.17.0
$ npx vite
You are using Node.js 20.17.0. Vite requires Node.js version 20.19+ or 22.12+. Please upgrade your Node.js version.
VITE v7.3.6 readyOn Node 18 the dev server crashes before it serves a file. A small app can start on Node 20.17 after the warning. That runtime is outside Vite 7’s supported range.
The range still allows 20.19, and Node 20 reached end of life on 2026-04-30. Choose a maintained line such as Node 22. Declare the supported range in package.json and pin the same Node release in local tooling and CI.
Removed options that break the build
An import of splitVendorChunkPlugin fails while Vite loads the config. For example, npx vite build can report this error.
$ npx vite build
failed to load config from …/vite.config.js
error during build:
SyntaxError: The requested module '…/vite/dist/node/index.js' does not provide an export named 'splitVendorChunkPlugin'The migration guide points to build.rollupOptions.output.manualChunks instead. Remove the old import and plugin call. If you still want a vendor chunk, this vite.config.js groups bundled modules from node_modules into one.
import { defineConfig } from 'vite'
export default defineConfig({
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) return 'vendor'
},
},
},
},
})With a dependency that stays in the bundle, the build can emit dist/assets/vendor-*.js alongside index-*.js. Check the output if the old chunk boundaries mattered.
Vite 7 uses the modern Sass API. Remove any api: "legacy" setting under css.preprocessorOptions.scss or css.preprocessorOptions.sass, and migrate any custom importers or functions that used the old API.
In a custom plugin, a transformIndexHtml hook written as { enforce, transform } becomes { order, handler }, the same object shape other plugin hooks use.
The default build target moved
Vite 7 changes the default build.target to 'baseline-widely-available'. Resolving a fresh config prints the browsers it means: chrome107, edge107, firefox104 and safari16.
Under Vite 6 the floor was Chrome 87 and Safari 14. If your users include Safari 15, set build.target to the browsers you support before you ship the upgrade, and test the result. The target controls syntax transforms. Browser APIs still need their own support checks or polyfills.