1

I'm trying to add apollo-angular to my Angular 19 project, but I'm getting the following output in the terminal:

We couldn't find 'esnext.asynciterable' in the list of library files
to be included in the compilation.

It's required by '@apollo/client/core' package so please add it to your tsconfig.


We couldn't enable 'allowSyntheticDefaultImports' flag.
It's required by '@apollo/client/core' package so please add it to your tsconfig.

The command I'm running after creating a new Angular 19 project is ng add apollo-angular

For reference this is my tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "strict": true,
    "noImplicitOverride": true,
    "noPropertyAccessFromIndexSignature": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "skipLibCheck": true,
    "isolatedModules": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "moduleResolution": "bundler",
    "importHelpers": true,
    "target": "es2022",
    "module": "es2022",
    "lib": ["esnext", "esnext.asynciterable"],
    "allowSyntheticDefaultImports": true
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true
  }
}

Screenshot of error: enter image description here

ng version shows:

Angular CLI: 19.0.4
Node: 22.12.0
Package Manager: npm 10.9.0
OS: darwin arm64

Angular: 19.0.3
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1900.4
@angular-devkit/build-angular   19.0.4
@angular-devkit/core            19.0.4
@angular-devkit/schematics      19.0.4
@angular/cli                    19.0.4
@schematics/angular             19.0.4
rxjs                            7.8.1
typescript                      5.6.3
zone.js                         0.15.0

Does anyone know how to get rid of these errors when running ng add apollo-angular?

1
  • Note that I've done all of the things mentioned in the error message, and I still get the same error messages. Commented Dec 11, 2024 at 1:24

2 Answers 2

2

The fix according to the github issues, seems to be to add esnext to the lib array of the tsconfig.json.

ng add apollo-angular not working correctly #1485

Cannot find name 'AsyncIterator' error in Typescript compilation process. #83

{
  "compileOnSave": false,
  "compilerOptions": {
    ...
    "target": "ES2022",
    "lib": ["esnext"],
    "module": "ES2022"
  },
  ...
}

OUTPUT:

enter image description here

Full tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "strict": true,
    "noImplicitOverride": true,
    "noPropertyAccessFromIndexSignature": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "skipLibCheck": true,
    "isolatedModules": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "moduleResolution": "bundler",
    "importHelpers": true,
    "target": "es2022",
    "module": "es2022",
    "lib": ["esnext"],
    "allowSyntheticDefaultImports": true
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true
  }
}
Sign up to request clarification or add additional context in comments.

7 Comments

Thank you Naren! That answers half the question but I'm still getting one error message even though I've set allowSyntheticDefaultImports in my tsconfig.json. "We couldn't enable 'allowSyntheticDefaultImports' flag. It's required by '@apollo/client/core' package so please add it to your tsconfig."
@mkelley33 I think we can add this to tsconfig.json, but after doing this change the error wen't away for me, are you still not able to install apollo-angular? because it got installed for me
Strangely enough when I removed the allowSyntheticDefaultImports from tsconfig, and I ran ng add apollo-angular, it put that flag in my tsconfig along with the libs, but now I'm getting the error about asynciterable again.
@mkelley33 Firstly make sure you have esnext added to lib array, as well as allowSyntheticDefaultImports added, then run npm cache clean --force to clean the cache then try adding again, you can also delete the .angular folder if present for additional safety.
@nareen-murali I tried all of that but still get both errors even with my tsconfig having esnext in libs and allowSyntheticDefaultImports set to true.
|
1

After adding lines that were described here I still received an error.

I dig somewhere that in fact you need to delete some of them.

For me it was failing when I had a config:

  "compilerOptions": {
    ....
    "module": "es2022",
    "lib": [
      "esnext",
      "esnext.asynciterable"
    ],
    "allowSyntheticDefaultImports": true
  },

I need to remove lines:

"esnext.asynciterable"
"allowSyntheticDefaultImports": true

Then command added back the missing items and succed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.