Closed
Description
Which @angular/* package(s) are the source of the bug?
compiler
Is this a regression?
No
Description
If you use environment variables and a specific file is missing, you now get an unspecific error for environment.ts file which not telling you, the specific file is missing like it was before.
For example: If the environment.development.ts
is declared in angular.json but missing for any reason like you do not want to check in, you get following exception, see bellow.
Reproduce:
- create a new application with `ng n angular-test-environment
- add environment config with
ng generate environments
- update environment.development.ts file and use in application
- start and test, it should work
- remove environment.development.ts and you get the unspecific error
Please provide a link to a minimal reproduction of the bug
https://github.com/inpercima/angular-test-environment
Please provide the exception or error you saw
[ERROR] TS2307: Cannot find module '../environments/environment' or its corresponding type declarations. [plugin angular-compiler]
src/app/app.component.ts:4:28:
4 │ import { environment } from '../environments/environment';
### Please provide the environment you discovered this bug in (run `ng version`)
```true
Angular CLI: 17.0.0
Node: 20.9.0
Package Manager: npm 10.1.0
OS: linux x64
Angular: 17.0.2
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1700.0
@angular-devkit/build-angular 17.0.0
@angular-devkit/core 17.0.0
@angular-devkit/schematics 17.0.0
@angular/cli 17.0.0
@schematics/angular 17.0.0
rxjs 7.8.1
typescript 5.2.2
zone.js 0.14.2
Anything else?
Before in version 16 is was an better description of what was missing:
An unhandled exception occurred: The ../environments/environment.development.ts path in file replacements does not exist.
See "/tmp/ng-kthknf/angular-errors.log" for further details.
error Command failed with exit code 127.