Repository navigation
Closed
Closed
Copy link
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
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.
Activity
fix(@angular-devkit/build-angular): add actionable error when file re…
fix(@angular-devkit/build-angular): add actionable error when file re…
fix(@angular-devkit/build-angular): add actionable error when file re…
fix(@angular-devkit/build-angular): add actionable error when file re…
fix(@angular-devkit/build-angular): add actionable error when file re…
evanliomain commentedon Dec 11, 2023
Hi,
it's seems that the fix break the fileReplacement features.
I saw this
import { access, constants } from 'node:fs/promises';in the commit.But
constantsdoes not belong tonode:fs/promises, but tonode:fs.Therefore,
constantsis undefined, and the access control always rise the Error.alan-agius4 commentedon Dec 11, 2023
@evanliomain,
constantsis exported fromnode:fs/promises. Likely you are using an unsupported Node.js version.evanliomain commentedon Dec 11, 2023
Indeed. I used node 16.14.0 and it's breaking.
With node 16.20.2 (lts/gallium) it work's !
Thank you @alan-agius4 for the answer.
alan-agius4 commentedon Dec 11, 2023
Node.js 16 is not supported by Angular version 17 as it is no longer in LTS. Please see: https://endoflife.date/nodejs
The current supported versions are
^18.13.0and^20.9.0.angular-automatic-lock-bot commentedon Jan 11, 2024
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.