Command
test
Is this a regression?
The previous version in which this bug was not present was
No — unit-test/Vitest builder is new; broken on Windows since it shipped
Description
Windows-only Failed to resolve import in vite:import-analysis; root-cause table (spec keys POSIX via toPosixPath vs setup-file key backslashes via path.join) → map miss → raw-source cascade; the one-line toPosixPath fix diff; note on why resolve.alias isn't a valid workaround
Minimal Reproduction
ng new repro --defaults --style=css --routing=false
cd repro
Then:
- tsconfig alias — add
"paths": { "@lib/*": ["src/lib/*"] } and "baseURL" to tsconfig.json
- aliased module — src/lib/greeting.ts →
export const greeting = 'hello';
- setup file — src/test-setup.ts →
import { greeting } from '@lib/greeting';
- wire the builder in
angular.json under the project's test target:
Expected: alias resolves (as it does at build time), tests run.
Actual (Windows): Failed to resolve import "@lib/greeting" from "src/test-setup.ts" — Plugin: vite:import-analysis, 0 tests. Same repo passes on macOS/Linux.
Exception or Error
Error: Failed to resolve import "@lib/greeting" from "src/test-setup.ts". Does the file exist?
Plugin: vite:import-analysis
Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI : 22.0.3
Angular : 22.0.2
Node.js : 22.22.3
Package Manager : npm 12.0.2
Operating System : win32 x64
┌───────────────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────────────┼───────────────────┼───────────────────┤
│ @angular-devkit/architect │ 0.2200.3 │ 0.2200.3 │
│ @angular-devkit/build-angular │ 22.0.3 │ ^22.0.3 │
│ @angular-devkit/core │ 22.0.3 │ ^22.0.3 │
│ @angular/animations │ 22.0.2 │ ^22.0.2 │
│ @angular/build │ 22.0.6 │ ^22.0.6 │
│ @angular/cdk │ 22.0.2 │ ^22.0.2 │
│ @angular/cli │ 22.0.3 │ ^22.0.3 │
│ @angular/common │ 22.0.2 │ ^22.0.2 │
│ @angular/compiler │ 22.0.2 │ ^22.0.2 │
│ @angular/compiler-cli │ 22.0.2 │ ^22.0.2 │
│ @angular/core │ 22.0.2 │ ^22.0.2 │
│ @angular/elements │ 22.0.2 │ ^22.0.2 │
│ @angular/forms │ 22.0.2 │ ^22.0.2 │
│ @angular/google-maps │ 22.0.2 │ ^22.0.2 │
│ @angular/localize │ 22.0.2 │ ^22.0.2 │
│ @angular/material │ 22.0.2 │ ^22.0.2 │
│ @angular/platform-browser │ 22.0.2 │ ^22.0.2 │
│ @angular/platform-browser-dynamic │ 22.0.2 │ ^22.0.2 │
│ @angular/router │ 22.0.2 │ ^22.0.2 │
│ ng-packagr │ 22.0.0 │ ^22.0.0 │
│ rxjs │ 7.8.2 │ ~7.8.0 │
│ typescript │ 6.0.3 │ ~6.0.0 │
│ vitest │ 4.1.10 │ ^4.1.10 │
│ zone.js │ 0.16.2 │ ~0.16.0 │
└───────────────────────────────────┴───────────────────┴───────────────────┘
Anything else relevant?
Windows-only, only setup files importing first-party modules, patch-package verification numbers
Command
test
Is this a regression?
The previous version in which this bug was not present was
No — unit-test/Vitest builder is new; broken on Windows since it shipped
Description
Windows-only
Failed to resolve importinvite:import-analysis; root-cause table (spec keys POSIX viatoPosixPathvs setup-file key backslashes viapath.join) → map miss → raw-source cascade; the one-linetoPosixPathfix diff; note on whyresolve.aliasisn't a valid workaroundMinimal Reproduction
ng new repro --defaults --style=css --routing=falsecd reproThen:
"paths": { "@lib/*": ["src/lib/*"] }and"baseURL"to tsconfig.jsonexport const greeting = 'hello';import { greeting } from '@lib/greeting';angular.jsonunder the project'stesttarget:ng testExpected: alias resolves (as it does at build time), tests run.
Actual (Windows):
Failed to resolve import "@lib/greeting" from "src/test-setup.ts" — Plugin: vite:import-analysis, 0 tests. Same repo passes on macOS/Linux.Exception or Error
Your Environment
Anything else relevant?
Windows-only, only setup files importing first-party modules, patch-package verification numbers