kmanaseryan / ngx-envconfig Goto Github PK
View Code? Open in Web Editor NEWConfiguration utility for Angular based on the environment variables
License: MIT License
Configuration utility for Angular based on the environment variables
License: MIT License
Hello,
while using the ngx-envconfig library, i can't use the production mode due to an error during application startup:
production main.91723b488af13390246c.js:1 TypeError: Cannot read property 'HOST_API' of undefined at t.getApi (main.91723b488af13390246c.js:1) at t.intercept (main.91723b488af13390246c.js:1) at t.handle (main.91723b488af13390246c.js:1) at t.intercept (main.91723b488af13390246c.js:1) at t.handle (main.91723b488af13390246c.js:1) at t.handle (main.91723b488af13390246c.js:1) at e.project (main.91723b488af13390246c.js:1) at e._tryNext (main.91723b488af13390246c.js:1) at e._next (main.91723b488af13390246c.js:1) at e.next (main.91723b488af13390246c.js:1)
do you have an idea how i can fix this error?
thanks in advance,
Describe the bug
When running in Angular 9.1.0, I get the following output:
ERROR in node_modules/ngx-envconfig/src/config.module.d.ts:7:37 - error NG6005: ConfigModule.forRoot returns a ModuleWithProviders type without a generic type argument. Please add a generic type argument to the ModuleWithProviders type. If this occurrence is in library code you don't control, please contact the library authors.
7 static forRoot(env: EnvConfig): ModuleWithProviders;
I would fix this, but I have no idea what type argument it's expecting (I'm new to Angular).
To Reproduce
Steps to reproduce the behavior:
ngx-envconfig
ngx-envconfig
readmeng serve
and observe the errorExpected behavior
The module to load and ngx-envconfig
to be available in my Angular components.
Environment (please complete the following information):
Can we make a package compatible with recent Angular version?
The process of building an API url is probably outside the scope of this library due to a wide variety of application specific conventions for APIs. For instance, the getApi
implementation is useless if you have an API with multiple hosts.
In the interest of keeping this library focused on "environment configuration," I would propose you remove the getApi
method from ConfigService.
While running the command ng build --configuration=production
I am getting the following error:
ERROR in Error during template compile of 'AppModule'
Function calls are not supported in decorators but 'ConfigModule' was called.
Here is the code that I am using the app.module file
`import { ConfigModule, ConfigService } from 'ngx-envconfig';
import { environment } from '../environments/environment'; // <-- add this line
const appRoutes: Routes = [
{ path: 'charts/:id', component: PiechartComponent }
];
@NgModule({
declarations: [
AppComponent,
BarchartComponent,
LinechartComponent,
PiechartComponent
],
imports: [
BrowserModule,
HttpModule,
HttpClientModule,
AmChartsModule,
RouterModule.forRoot(appRoutes),
ConfigModule.forRoot(environment) // <-- pass environment variable
],
providers: [ServerService],
bootstrap: [AppComponent]
})
export class AppModule { }`
In getting started code snippets, ConfigService and ConfigeModule are being used from local module folder instead of installed ones.
Describe the bug
After using this package my component tests started failing with the following error
To Reproduce
Steps to reproduce the behavior:
FAIL apps/my-app/src/app/auth/login/login.component.spec.ts ● Test suite failed to run Jest encountered an unexpected token This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript. By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules". Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config. • If you need a custom transformation specify a "transform" option in your config. • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option. You'll find more details and examples of these config options in the docs: https://jestjs.io/docs/en/configuration.html Details: D:\MYapp\mayapp-rocket-shorts-ng7\node_modules\ngx-envconfig\index.js:1 ({"Object.":function(module,exports,require,__dirname,__filename,global,jest){export { ConfigModule } from './src/config.module'; ^^^^^^ SyntaxError: Unexpected token export at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:471:17) at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:513:25) at Object. (apps/my-app/src/app/auth/login/login.component.ts:1162:25)`I have been trying to fix this from hrs. But not able to.
I am on angular v7.
I tried upgrading from jest 23.6.0 to 24.7.1
tried upgrading from jest-preset-angular 6.0.2 to 7.1.0
upgrading angular-builders/jest from 7.2.1 to 7.4.2
But this error still persists on both the earlier and the later vesions stated above.
Can you give me an example of how we can use this package and still write a working jest test.
Describe the bug
TypeError: Cannot read property 'HOST_API' of undefined
To Reproduce
Steps to reproduce the behavior:
Expected behavior
No errors
Environment (please complete the following information):
Additional context
From what I've see, the _config variable (in config.service.js) is never initialized in time
Is there a way to ensure the _config is fully loaded?
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.