网站搜索

typescript - 更新 Vue 包、i18next 后,node-modules 中出现构建错误


我正在尝试将 i18n 包更新到新版本 i18next。更新后,在项目编译期间出现了许多错误。我找到的解决方法是在 tsconfig 文件的编译器选项中添加 skipLibCheck。这样修复了编译错误,一切运行正常。
现在我面临的问题是,以前在编译期间出现的错误正在导致我的应用构建失败。

在使用 vue-cli-service 构建时,有没有办法忽略对 node_modules 文件夹的 TypeScript 检查?

在 tsconfig.json 中我已经添加了:

  "compilerOptions": {
    "skipLibCheck": true,
  },

和

  "exclude": [
    "node_modules",
    "node_modules/*",
  ]

示例错误:

答案#1

我找到了解决方案。这个解决方案在使用 vue-cli 时相关。

vue.config.js
module.exports = {
  chainWebpack: config => {
     config.plugin('fork-ts-checker').tap(args => {
      args[0].checkSyntacticErrors = false;
      return args;
    });
  }
}