1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Nx Angular - no such file or directory, open...

Discussão em 'Angular' iniciado por Jacques, Maio 14, 2025.

  1. Jacques

    Jacques Guest

    I've spent some time working on a PowerShell project to automate some builds of my C# and Angular apps which are based on @Nrwl NX monorepos. Prior to this everything worked fine, but when I try a simple:

    nx build --baseHref=/apps/admin/ --deployUrl=/apps/admin/ --watch


    I now get the error

    ENOENT: "no such file or directory, open 'd:\Projects\TheApp\Source\Angular.Apps/apps/the-client/src/environments/environment.prod.ts'"


    Problem: I assume it's looking for environment.prod.ts because the replaceFile section, but since I'm building in local dev I would have though it shouldn't do the replacement at all.
    Also: It's looking for the APP-CLIENT environment file even though I'm building the APP-ADMIN app.

    Some points that could have caused issues during my build automation project:


    1. I renamed all the app configurations in workspace.json. So for example "production" became "production-client1" which makes use of the environment.prod.client1.ts file during replacement

      "fileReplacements": [
      {
      "replace": "apps/app-admin/src/environments/environment.ts",
      "with": "apps/app-admin/src/environments/environment.prod.orgb.ts" }
      ],


    2. In 1) above I mentioned the file environment.prod.client1.ts which is originally the environment.prod.ts file. Since the error mentions that it can't find this file it could be that the problem is either here or that I should changed some additional configuration to make this work?

    Final note: My powershell cmdlet calls the following command:

    nx build portfolio-client --deleteOutputPath=false --baseHref=/apps/client/ --deployUrl=/apps/client/ --configuration=staging-client-client1


    And this works like a charm as does the admin app and the variations for each client. It's only during dev builds that I'm experiencing these issues.

    Edit 1:
    I created dummy files for environment.prod.ts and environment.staging.ts in the two "application" type projects that I have and this resolved the problem. These files are blank though so not sure why building for Dev/local isn't just working off the environment.ts file

    Continue reading...

Compartilhe esta Página