Troubleshooting
Common Nx + Vite issues and direct fixes.
TypeScript Paths Not Resolving
Symptoms:
- Imports like
@my-org/libfail during dev/build.
Fix:
- Add
nxViteTsPaths()toplugins. - Confirm project
tsconfigpath aliases are correct.
Build Output in Wrong Directory
Symptoms:
- Artifacts appear inside project folder or unexpected dist path.
Fix:
- Set
root: __dirname. - Set
build.outDirrelative to workspace root (not project root).
Library Types Missing for Consumers
Symptoms:
- Published package compiles but downstream TS projects fail type lookup.
Fix:
- Add
vite-plugin-dtsand verify output. - Ensure package metadata points to types (
types/exports).
Assets Not Copied
Symptoms:
- Markdown/license/static files missing from output.
Fix:
- Use
nxCopyAssetsPlugin([...])for non-public files. - Keep
public/assets in Vite public flow.
Tests Not Running or Cached Correctly
Symptoms:
- Vitest behaves inconsistently between local and CI.
Fix:
- Set
test.reporters,test.environment, and deterministic cache/coverage dirs. - Validate with
nx run <project>:test.
Slow Library Builds
Symptoms:
- Build times grow significantly after adding DTS generation.
Fix:
- Set
skipDiagnostics: truein local development. - Keep strict diagnostics in CI or release checks.
Migration Regressions from Webpack
Symptoms:
- Feature parity gaps after moving to Vite.
Fix:
- Identify Webpack-only behavior first.
- Replace loader/plugin behavior with Vite equivalents incrementally.
- Stop migration for unsupported critical features.