title: In Angualr why OpenApi Generated ApiModule doesn’t register when declared in node_modules but works outside that folder?
body: <p>I’m having an issue. I need to consume OpenApi Generated files (services, interfaces) via NPM package. The problem it doesn’t work when it’s in node_modules, but if I move it outside this folder it works. ApiModule comes as undefined when in node_modules for some reason. Github link in the bottom is documentation how to use it.</p>
  <p>The project builds, it detects the files in path but on launching website I get error:</p>
  <pre><code>app.module.ts:30 Uncaught TypeError: Cannot read properties of undefined (reading 'forRoot')
      at Module.6747 (app.module.ts:30)
      at __webpack_require__ (bootstrap:19)
      at Module.4431 (environment.ts:16)
      at __webpack_require__ (bootstrap:19)
      at __webpack_exec__ (log$:23)
      at log$:23
      at Function.__webpack_require__.O (chunk loaded:23)
      at log$:23
      at webpackJsonpCallback (jsonp chunk loading:33)
      at main.js:1
  </code></pre>
  <p>AppModule:</p>
  <pre><code>import { NgModule } from '@angular/core';
  import { BrowserModule } from '@angular/platform-browser';
  
  import { AppComponent } from './app.component';
  
  ////// added
  import { HttpClientModule } from '@angular/common/http';
  import {
    ApiModule,
    Configuration,
    ConfigurationParameters,
  } from 'client-petstore';
  
  
  export function apiConfigFactory(): Configuration {
    const params: ConfigurationParameters = {
      basePath: 'https://localhost:4200',
    };
    return new Configuration(params);
  }
  ////// end
  
  @NgModule({
    declarations: [
      AppComponent
    ],
    imports: [
      BrowserModule,
      ////// added
      ApiModule.forRoot(apiConfigFactory),
      HttpClientModule
      ////// end
    ],
    providers: [],
    bootstrap: [AppComponent]
  })
  export class AppModule { }
  </code></pre>
  <p>I have tried this on 2 different machines running Angular 12 (Node.js v12 and v16) with:</p>
  <ul>
  <li><p>my locally generated file;</p>
  </li>
  <li><p>“npm typescript-codegen-petstore” downloaded (requires adding
  override keyword and adding  in places it fails);</p>
  </li>
  <li><p><a href="https://github.com/OpenAPITools/openapi-generator/tree/master/samples/client/petstore/typescript-angular-v12-provided-in-root/builds/with-npm" rel="nofollow noreferrer">https://github.com/OpenAPITools/openapi-generator/tree/master/samples/client/petstore/typescript-angular-v12-provided-in-root/builds/with-npm</a> (<a href="https://download-directory.github.io" rel="nofollow noreferrer">https://download-directory.github.io</a> to download this section)</p>
  </li>
  </ul>
  <p>If I put in a different folder than node_modules it works, inside it doesn’t. Any help or ideas? Thanks.</p>