Closed PR4SAN closed 8 months ago
Yeah, got same error
In angular.json
build target
-"browser": "src/main.ts",
+"main": "src/main.ts",
serve target
-"buildTarget": "ng-app17:build:production"
+"browserTarget": "ng-app17:build:production"
-"buildTarget": "ng-app17:build:development"
+"browserTarget": "ng-app17:build:development"
Let me know if that works for you please.
Note that it will use the webpack builder which @ngx-env/builder is built on top of. There are still issues with using the esbuild plugins, once stable and enough documented, I'll release a new v17 compatible with vite and esbuild.
@chihab the workaround provided did the trick 😄 Thanks for your time and assistance. Look forward to the new version 🥇 👍🏼
Could you give npx ng add @ngx-env/builder@17.0.0-alpha.0
a try?
Make sure your build architect target has "builder": "@ngx-env/builder:application"
.
@chihab I tested the command provided npx ng add @ngx-env/builder@17.0.0-alpha.0
and no manual configuration nor further actions were required. I was able to use the environment variables 👍🏼
The build architect target property in the angular.json
file was automatically updated to @ngx-env/builder:application
The latest available version of @ngx-env/core is 16.1.3 depending on Angular 16. I also cannot see updated code in the repository so for the moment I cannot update to angular version 17 until this package is updated. Does this code need more work for Angular 17 support or is simply a dependency update?
@ngx-env/core@16 should work with Angular 17 but its peer dep indicates ^16 so you should have a peer dep missing issue but if you force, it should work, in theory.
Now, I would suggest not to use @ngx-env/core mainly because the good practice is not put the process.env in the template nor in the component code but rather reference it in your angular environment files (or any configuration file).
Thank you @chihab . I was using the env pipe and migrated everything as you said and removed the dependency. Everything works.
With angular 17 this doesn't work and throws an error of
Error: Schema validation failed with the following errors: Data path "" must have required property 'main'.