繁体   English   中英

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

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

因此,我正在尝试将带有 graphql 文件的打字稿项目编译到 heroku 并收到以下错误消息:

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

我的 tsconfig.json 内容如下:

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

我的 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"
  }

我的文件目录如下:

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

我忽略了什么,我该如何解决?

这是一种解决方法,而不是修复

我还不知道根本原因是什么,但我目前正在通过将以下内容添加到compilerOptions来解决:

  "compilerOptions": {
    "skipLibCheck": true
  }

您应该能够保持编译器选项的 rest 不变。 我在这个GitHub 问题评论中找到了这个解决方法

暂无
暂无

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

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