Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
inpercima opened this issue Nov 11, 2023 · 5 comments · Fixed by #26367
Closed

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

inpercima opened this issue Nov 11, 2023 · 5 comments · Fixed by #26367

Comments

@inpercima
Copy link

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.
@JoostK JoostK transferred this issue from angular/angular Nov 11, 2023
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Nov 15, 2023
…placement is missing

This commits adds an actionable error when the file to replace with is missing.

Closes angular#26333
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Nov 15, 2023
…placement is missing

This commits adds an actionable error when the file to replace with is missing.

Closes angular#26333
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Nov 15, 2023
…placement is missing

This commits adds an actionable error when the file to replace with is missing.

Closes angular#26333
clydin pushed a commit that referenced this issue Nov 15, 2023
…placement is missing

This commits adds an actionable error when the file to replace with is missing.

Closes #26333
clydin pushed a commit that referenced this issue Nov 15, 2023
…placement is missing

This commits adds an actionable error when the file to replace with is missing.

Closes #26333

(cherry picked from commit 155341f)
@evanliomain
Copy link

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.

@alan-agius4
Copy link
Collaborator

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

@evanliomain
Copy link

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
Copy link
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.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants