简体   繁体   English

Heroku:使用 graphql 文件编译 Typescript 时出错 - 错误 TS2307:找不到模块“graphql”或其相应的类型声明

[英]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:因此,我正在尝试将带有 graphql 文件的打字稿项目编译到 heroku 并收到以下错误消息:

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:我的 tsconfig.json 内容如下:

{
    "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:我的 package.json 内容如下:

{
  "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来解决:

  "compilerOptions": {
    "skipLibCheck": true
  }

You should be able to leave the rest of the compiler options intact.您应该能够保持编译器选项的 rest 不变。 I found this workaround in this GitHub Issue comment我在这个GitHub 问题评论中找到了这个解决方法

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 src/index.ts:12:22 - 错误 TS2307:找不到模块“./schema.graphql”或其相应的类型声明 - src/index.ts:12:22 - error TS2307: Cannot find module './schema.graphql' or its corresponding type declarations 错误 TS2307:找不到模块“路径”或其相应的类型声明。 尝试使用 Knex 在 heroku 应用程序中迁移时 - error TS2307: Cannot find module 'path' or its corresponding type declarations. when trying to migrate in heroku app with Knex 错误 TS2307:找不到模块“fs”或其相应的类型声明 - error TS2307: Cannot find module 'fs' or its corresponding type declarations 错误 TS2307:找不到模块 '.shaders/vertex.glsl' 或其对应的类型声明 - error TS2307: Cannot find module '.shaders/vertex.glsl' or its corresponding type declarations TS2307 错误:找不到模块“../constants”或其相应的类型声明 - TS2307 Error: Cannot find module '../constants' or its corresponding type declarations 错误 TS2307:找不到模块或其对应的类型声明。 在 Github 操作 - error TS2307: Cannot find module or its corresponding type declarations. on Github Actions TS2307:找不到模块“@/*”或其对应的类型声明 - TS2307: Cannot find module '@/*' or its corresponding type declarations 业力,Webpack & Typescript:TS2307:找不到模块“log4js”或其相应的类型声明 - Karma, Webpack & Typescript: TS2307: Cannot find module 'log4js' or its corresponding type declarations 如何修复/忽略此控制台错误“TS2307:找不到模块‘@components/common/ButtonBlock’或其相应的类型声明。” - How fix/ignore this console error “TS2307: Cannot find module '@components/common/ButtonBlock' or its corresponding type declarations.” 插件 typescript:@rollup/plugin-typescript TS2307:找不到模块“./App.svelte”或其相应的类型声明 - Plugin typescript: @rollup/plugin-typescript TS2307: Cannot find module './App.svelte' or its corresponding type declarations
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM