Skip to content

Migrating to @nx/vitest from @nx/vite

Vitest functionality has been split from @nx/vite into a standalone @nx/vitest package. This provides better separation of concerns and allows vitest to be used independently of vite.

  • @nx/vite:vitest@nx/vitest:configuration
  • @nx/vite:test@nx/vitest:test
  • @nx/vite/plugin (for vitest) → @nx/vitest
Terminal window
npm install --save-dev @nx/vitest
# or
pnpm add -D @nx/vitest
# or
yarn add -D @nx/vitest

Before:

{
"targets": {
"test": {
"executor": "@nx/vite:test",
"options": {
"config": "vite.config.ts"
}
}
}
}

After:

{
"targets": {
"test": {
"executor": "@nx/vitest:test",
"options": {
"config": "vite.config.ts"
}
}
}
}

Before:

{
"plugins": [
{
"plugin": "@nx/vite/plugin",
"options": {
"testTargetName": "test"
}
}
]
}

After:

{
"plugins": [
{
"plugin": "@nx/vitest",
"options": {
"testTargetName": "test"
}
}
]
}

When adding vitest to new projects:

Terminal window
# Old
nx g @nx/vite:vitest my-project
# New
nx g @nx/vitest:configuration my-project

Nx 23 removed all vitest support from @nx/vite. The @nx/vite:test executor, the @nx/vite:vitest generator, and vitest target inference in @nx/vite/plugin no longer exist in v23. Everything is now provided exclusively by @nx/vitest.

If you are upgrading to Nx 23, the ensure-vitest-package-migration migration runs automatically via nx migrate and handles the conversion for you:

  • Installs @nx/vitest when vitest usage is detected in the workspace.
  • Swaps every @nx/vite:test reference (project targets and targetDefaults) to @nx/vitest:test.
  • Splits vitest options out of @nx/vite/plugin registrations into dedicated @nx/vitest plugin entries.
  • Adds an @nx/vitest plugin entry alongside any default-config @nx/vite/plugin registration.

See the migration reference for full details on what the automated migration does. For manual steps, follow the guide above.

  • vite.config.ts / vitest.config.ts: No changes needed
  • Test files: No changes needed
  • vitest.config.ts: No changes needed

File an issue at https://github.com/nrwl/nx/issues