简体   繁体   中英

Heroku: error compiling Typescript with graphql files - error TS2307: Cannot find module 'graphql' or its corresponding type declarations

So i'm attempting to compile a typesscript project with graphql files to heroku and am receiving the following error message:

node_modules/@types/graphql-upload/index.d.ts(10,35): error TS2307: Cannot find module 'graphql' or its corresponding type declarations.

My tsconfig.json reads as follows:

{
    "compilerOptions": {
      "outDir": "src",
      "rootDir": "src",
      "lib": ["ESNext"],
      "target": "ES6",
      "esModuleInterop": true,
      "strict": true,
      "types": ["@types/graphql-upload"]
    },
    "include": ["src/**/*"],
    "exclude": [""]
}

and my package.json reads as follows:

{
  "engines": {
    "node": "10.16.0",
    "npm": "6.5.0"
  },
  "scripts": {
    "start": "node src/index",
    "clean": "rm -rf src",
    "build": "tsc",
  },
  "dependencies": {
    "@types/graphql-upload": "^8.0.3",
    "@types/node-fetch": "^2.5.7",
    "graphql": "^14.7.0",
    "graphql-cli": "^3.0.5",
    "graphql-import": "^0.7.1",
  },
  "devDependencies": {
    "@types/node": "^14.0.19",
    "ts-node": "^8.10.2",
    "ts-node-dev": "^1.0.0-pre.50",
    "typescript": "^3.9.6"
  }

My file directory is as follows:

src -
    generated -
              prisma.graphql
    resolvers -
              Mutation.ts
              Query.ts
index.ts
schema.graphql

What am I overlooking and how do I resolve this?

This is a workaround, NOT a fix

I don't know what the underlying cause is yet, but I am currently working around by adding the following to compilerOptions :

  "compilerOptions": {
    "skipLibCheck": true
  }

You should be able to leave the rest of the compiler options intact. I found this workaround in this GitHub Issue comment

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM