Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

370
Views
Nx Angular - no such file or directory, open 'd:\...\TheApp\Source\Angular.Apps/apps/app-client/src/environments/environment.prod.ts'

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

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I found the answer in the comments of the following GitHub reported issue: "Error: ENOENT: no such file or directory" for deleted file #3370

What it came down to was that the Nrwl file file-hasher.js makes use of git hashes and since I had not committed those changes it was looking for an old filename. I resolved it by staging and committing all my changes on the current branch.

Looking further this seems to be a bug that was later fixed in Nx 10.0.2 and up, which we haven't upgraded to yet.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!