2

Error Log On initiating application

While initiating the application it shows the following error and i tried couple of fixes from online which has mentioned below but none of them has worked requesting for suggestions and solutions

node_modules/@types/graphql/subscription/subscribe.d.ts(17,12): error TS2304: Cannot find name 'AsyncIterator'.
node_modules/@types/graphql/subscription/subscribe.d.ts(29,12): error TS2304: Cannot find name 'AsyncIterable'.
node_modules/graphql-tools/dist/stitching/makeRemoteExecutableSchema.d.ts(3,109): error TS2304: Cannot find name 'AsyncIterator'.

Fixes Tried as per google results

  1. Adding esnext.asynciterable to the tsconfig.json
  2. Adding esnext to the tsconfig.json

But none of them has worked. package.json

  "dependencies": {
    "async": "^2.6.0",
    "body-parser": "^1.18.2",
    "cookie-parser": "^1.4.3",
    "cors": "^2.8.4",
    "ejs": "^2.5.7",
    "errorhandler": "^1.5.0",
    "express": "^4.16.2",
    "express-graphql": "^0.6.12",
    "graphql": "^0.13.2",
    "graphql-tools": "^3.1.1",
    "ldapjs": "^1.0.1",
    "method-override": "^2.3.10",
    "moment": "^2.20.1",
    "mongoose": "^4.13.6",
    "morgan": "^1.9.0",
    "mysql": "^2.15.0",
    "node-schedule": "^1.3.0",
    "nodemiral": "^1.1.1",
    "pug": "^2.0.0-rc.4",
    "q": "^1.5.1",
    "request": "^2.85.0",
    "sendmail": "^1.2.0",
    "serve-favicon": "^2.4.5",
    "socket.io": "^2.0.4",
    "ts-node": "^3.3.0"
  },
  "devDependencies": {
    "@types/async": "^2.0.47",
    "@types/body-parser": "^1.16.8",
    "@types/chai": "^4.0.8",
    "@types/chai-http": "^3.0.3",
    "@types/cookie-parser": "^1.4.1",
    "@types/cors": "^2.8.3",
    "@types/errorhandler": "0.0.32",
    "@types/ldapjs": "^1.0.3",
    "@types/lodash": "^4.14.106",
    "@types/method-override": "0.0.31",
    "@types/mocha": "^2.2.44",
    "@types/mongodb": "^2.2.16",
    "@types/mongoose": "^4.7.28",
    "@types/morgan": "^1.7.35",
    "@types/mysql": "^2.15.3",
    "@types/node-schedule": "^1.2.2",
    "@types/request": "^2.47.0",
    "@types/serve-favicon": "^2.2.30",
    "@types/socket.io": "^1.4.32",
    "chai": "^4.1.2",
    "chai-http": "^3.0.0",
    "grunt": "^1.0.1",
    "grunt-concurrent": "^2.3.1",
    "grunt-contrib-copy": "^1.0.0",
    "grunt-contrib-watch": "^1.0.0",
    "grunt-mocha-test": "^0.13.3",
    "grunt-newer": "^1.3.0",
    "grunt-nodemon": "^0.4.2",
    "grunt-ts": "^6.0.0-beta.17",
    "grunt-tslint": "^5.0.1",
    "grunt-typedoc": "^0.2.4",
    "mocha": "^4.0.1",
    "mocha-typescript": "^1.1.12",
    "nodemon": "^1.12.4",
    "tslint": "^5.8.0",
    "typescript": "^2.6.2"
  }
Rigin Oommen
  • 3,060
  • 2
  • 20
  • 29
  • Can you try to upgrade TypeScript? I am using 2.9.1 and it works for me. If that doesn't help, it would be great if would probably help the next responder if you could post your tsconfig.json file here too. – Mikael Lirbank Aug 03 '18 at 15:41

2 Answers2

2

Delete node modules then:-

npm install 
npm install --save graphql-subscriptions
npm install --save @types/graphql
npm install --save @types/ws

add the following in tsconfig.json

"compilerOptions": {
  "lib": [
     "esnext.asynciterable"
   ]
AConsumer
  • 2,461
  • 2
  • 25
  • 33
  • Hello Shivendra Gupta, I had installed the packages but it still returns the same error. – Rigin Oommen Aug 06 '18 at 08:42
  • Delete node modules and then do -> npm install – AConsumer Aug 06 '18 at 08:49
  • have u added "compilerOptions": { "lib": [ "esnext.asynciterable" ] in tsconfig.json ? – AConsumer Aug 06 '18 at 08:52
  • Hey Shivendra Gupta, I tried the mentioned steps now i am getting the following errors – Rigin Oommen Aug 06 '18 at 09:21
  • node_modules/@types/graphql/subscription/subscribe.d.ts(36,13): error TS2304: Cannot find name 'AsyncIterator'. – Rigin Oommen Aug 06 '18 at 09:21
  • node_modules/@types/graphql/subscription/subscribe.d.ts(47,12): error TS2304: Cannot find name 'AsyncIterator'. – Rigin Oommen Aug 06 '18 at 09:22
  • node_modules/@types/graphql/subscription/subscribe.d.ts(75,12): error TS2304: Cannot find name 'AsyncIterable'. – Rigin Oommen Aug 06 '18 at 09:22
  • node_modules/apollo-link/node_modules/@types/graphql/subscription/subscribe.d.ts(17,12): error TS2304: Cannot find name 'AsyncIterator'. node_modules/apollo-link/node_modules/@types/graphql/subscription/subscribe.d.ts(29,12): error TS2304: Cannot find name 'AsyncIterable'. node_modules/graphql-tools/dist/stitching/makeRemoteExecutableSchema.d.ts(3,109): error TS2304: Cannot find name 'AsyncIterator'. – Rigin Oommen Aug 06 '18 at 09:22
  • can you share your repository ? – AConsumer Aug 06 '18 at 09:27
  • Hello Shivendra, Actually its an internal project and under NDA. So i cannot share it outside. I am really sorry. But expecting your support – Rigin Oommen Aug 07 '18 at 06:59
  • Shivendra i had fixed this issue. the root cause was due to incompaitablity of the pakages with the project version. – Rigin Oommen Oct 15 '19 at 10:24
1

I encountered the same problem and adding

"lib": ["es2017", "esnext", "esnext.asynciterable"]

to my tsconfig.json did not help, which was frustrating.

I went through lots of suggestions and eventually the answer by Shivendra solved it for me. Hope this will help others coming here in the future.

wfreude
  • 492
  • 3
  • 10