Skip to content

Missing environment.development.ts results in unspecific error for environment #26333

Closed

Description

@inpercima

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.

Activity

  1. transferred this issue fromangular/angularon Nov 11, 2023
  2. added 3 commits that reference this issue on Nov 15, 2023
    6b58010
    838482f
    0c874bd
  3. added 2 commits that reference this issue on Nov 15, 2023
    155341f
    fa4d8ff
  4. evanliomain commented on Dec 11, 2023

    @evanliomain

    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 constants does not belong to node:fs/promises, but to node:fs.
    Therefore, constants is undefined, and the access control always rise the Error.

  5. alan-agius4 commented on Dec 11, 2023

    @alan-agius4
    Collaborator

    @evanliomain, constants is exported from node:fs/promises. Likely you are using an unsupported Node.js version.

  6. evanliomain commented on Dec 11, 2023

    @evanliomain

    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.

  7. alan-agius4 commented on Dec 11, 2023

    @alan-agius4
    Collaborator

    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.0 and ^20.9.0.

  8. angular-automatic-lock-bot commented on Jan 11, 2024

    @angular-automatic-lock-bot

    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.

  9. locked and limited conversation to collaborators on Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions