【问题标题】:TS2307: Cannot find module '_rc-trigger@5.2.0@rc-trigger' or its corresponding type declarationsTS2307:找不到模块 '_rc-trigger@5.2.0@rc-trigger' 或其对应的类型声明
【发布时间】:2021-04-15 11:27:18
【问题描述】:

当我尝试在 GitLab 上而不是在我的设备上部署应用程序时,会发生此错误。 最近刚把Antd更新到最后一版,出现了。

仅在我尝试在 Gitlab 上构建时发生

ERROR in /usr/src/app/node_modules/antd/es/tooltip/placements.d.ts
ERROR in /usr/src/app/node_modules/antd/es/tooltip/placements.d.ts(16,73):
TS2307: Cannot find module '_rc-trigger@5.2.0@rc-trigger' or its corresponding type declarations.
ERROR in /usr/src/app/node_modules/antd/lib/tooltip/placements.d.ts
ERROR in /usr/src/app/node_modules/antd/lib/tooltip/placements.d.ts(16,73):
TS2307: Cannot find module '_rc-trigger@5.2.0@rc-trigger' or its corresponding type declarations.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! optimax@1.1.6 build:dev: `webpack -p --env.stage --env.optimax --max_old_space_size=512`
npm ERR! Exit status 2

tsconfig.json

{
  "compileOnSave": true,
  "compilerOptions": {
    "outDir": "./dist/",
    "noImplicitAny": true,
    "module": "esnext",
    "target": "es6",
    "jsx": "react",
    "moduleResolution": "node",
    "skipDefaultLibCheck": true,
    "strictNullChecks": true,
    "allowJs": true,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "inlineSources": true,
    "sourceMap": true,
    "experimentalDecorators": true,
    "types": ["react", "node"],
    "typeRoots": ["node_modules/@types"],
    "baseUrl": "./",
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "**/*.spec.ts"]
}

【问题讨论】:

  • 你能分享你的 package.json + ci yml 文件吗?
  • 确定@tmhao2005 我可以只添加包json而不是yml文件
  • 你说它发生在 Gitlab CI 上对吧?那么你的部署文件在哪里呢?
  • 这看起来像是node_modules 中的类型检查错误,这对我们来说是不必要的。尝试使用 skipLibCheck 而不是 DEPRECATED skipDefaultLibCheck 将其关闭
  • 哦,谢谢。您可以将其添加为答案。谢谢@tmhao2005

标签: reactjs typescript antd


【解决方案1】:

有时我们会遇到在node_modules 中输入错误的问题,这可能与我们的代码无关。我个人热衷于在大多数用例中将其关闭。

在您的配置中,您也将其关闭,但它是 skipDefaultLibCheck 已弃用的值,将替换为 skipLibCheck

{
  "skipLibCheck": true,
}

【讨论】:

    猜你喜欢
    • 2021-08-27
    • 2022-10-17
    • 2021-11-23
    • 2021-05-14
    • 2021-04-08
    • 2022-10-06
    • 2021-12-21
    • 2021-03-17
    • 2021-01-19
    相关资源
    最近更新 更多