chihab / dotenv-run

Seamlessly load environment variables. Supports cli, esbuild, rollup, vite, webpack, angular. ESM and Monorepos.
238 stars 17 forks source link

ng build throws rxjs switchmap error #56

Closed scry-UrjitDesai closed 8 months ago

scry-UrjitDesai commented 1 year ago

Hey, I am trying to build my project using ng build but am getting the following error:

An unhandled exception occurred: (0 , rxjs_1.switchMap) is not a function

I am using import.meta.env everywhere.

Here is my env.d.ts

interface ImportMeta {
  readonly env: ImportMetaEnv;
}

interface ImportMetaEnv {
  /**
   * Built-in environment variable.
   * @see Docs https://github.com/chihab/ngx-env#ng_app_env.
   */
  readonly NG_APP_ENV: string;
  // Add your environment variables below
  // readonly NG_APP_API_URL: string;
  [key: string]: any;
}
declare namespace NodeJS {
  export interface ProcessEnv {
    readonly NG_APP_ENV: string;
    // Add your environment variables below
    [key: string]: any;
  }
}

rxjs version- 6.5.5

scry-UrjitDesai commented 1 year ago

I also tried using process.env instead of import.meta It is still giving me the same error. I was able to get rid of the error by upgrading the rxjs package to >7.0 but I would still like to know if there is any other solution apart from this. Thanks !

chihab commented 1 year ago

It would be nice to have a repo reproducing the issue.

chihab commented 1 year ago

Closing the issue. Feel free to re-open the issue with a reproducing project (preferrably on stackblitz).

kevinpiske commented 10 months ago

I had the same problem and solved it downgrading the @ngx-env/builder version to 15.1.0, since my Angular version is 14.

Check your Angular version and find a lib version that uses the same Angular version.

digital88 commented 9 months ago

Yes, can confirm. v16 throws error like OP posted, while v15 works. I have pretty old angular + rxjs repo, maybe can build a repro later.