【问题标题】:tsconfig.json file outside of project directory项目目录之外的 tsconfig.json 文件
【发布时间】:2020-12-29 11:41:44
【问题描述】:

我有一个项目portal。随着我的开发,我意识到我本质上需要存储库中的多个项目。因此,我现在有一个这样的项目结构:

我想知道,是否可以在 portalshop 目录之外拥有 tsconfig.json 文件,这意味着 typescript 编译器选项将适用于两个项目?当我在门户项目上执行npm run serve 时,我似乎遇到了这个错误:

Error: Cannot find "C:\Git\ui\portal\tsconfig.json" file. Please check webpack and ForkTsCheckerWebpackPlugin configuration. 
Possible errors: 
  - wrong `context` directory in webpack configuration (if `tsconfig` is not set or is a relative path in fork plugin configuration)
  - wrong `tsconfig` path in fork plugin configuration (should be a relative or absolute path)

我不太确定它来自哪里,因为我的代码库中没有定义这样的文件路径。

tsconfig.json的内容是:

{
 "compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": "portal",
"types": [
  "webpack-env"
],
"paths": {
  "@/*": [
    "src/*"
  ]
},
"lib": [
  "esnext",
  "dom",
  "dom.iterable",
  "scripthost"
]
 },
 "include": [
  "portal/src/**/*.ts",
  "portal/src/**/*.tsx",
   "portal/src/**/*.vue"
 ],
 "exclude": [
 "node_modules"
 ]
}

【问题讨论】:

    标签: typescript vue.js single-page-application eslint


    【解决方案1】:

    试试这个:保留现有的tsconfig.json,然后在每个文件夹中创建一个tsconfig.json,内容如下:

    {
        "extends": "../tsconfig.json"
    }
    

    【讨论】:

      猜你喜欢
      • 2013-01-12
      • 2012-05-23
      • 2012-03-27
      • 2016-12-22
      • 2013-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-31
      相关资源
      最近更新 更多