【问题标题】:How to ignore React.js source files in a clean Nest.js installation?如何在干净的 Nest.js 安装中忽略 React.js 源文件?
【发布时间】:2020-05-25 00:14:18
【问题描述】:

我有一个干净的 Nest.js 安装和一个名为“client”的文件夹,其中包含 create-react-app 干净安装。

假设项目结构是:

./
  ...some Nest.js folders...
  client <- React.js is here
  ...some more Nest.js folders...
  tsconfig.json <- here the "client" folder is excluded in the "exclude" block

我试图在项目根文件夹中运行 npm start:dev 以使 Nest.js 编译所有文件,但它一直在抱怨“除非提供了 '--jsx' 标志,否则无法使用 JSX。”。

我已将“客户端”文件夹添加到 Nest.js 安装的 tsconfig.json 中的“排除”块中。 我仍然有这个错误

我做错了什么?如何完全忽略 Nest.js 编译脚本的客户端文件?

tsconfig.json 内容:

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true
  },
  "exclude": [
    "client",
    "node_modules",
    "dist"
  ]
}

【问题讨论】:

  • Repro 真的很简单。重现步骤: 1. 全局安装 Nest.js 并创建一个新的 Nest.js 安装 2. 在安装文件夹中创建一个文件夹“client” 3. 全局安装“create-react-app”工具并在其中创建一个新的 React 安装“client”文件夹 4. 转到项目根文件夹并运行“npm run start:dev”并查找错误

标签: javascript reactjs typescript nestjs tsconfig


【解决方案1】:

您也必须排除tsconfig.build.json 中的文件夹

{
  "extends": "./tsconfig.json",
  "exclude": [
    "node_modules",
    "test",
    "dist",
    "**/*spec.ts",
    "client"
  ]
}

【讨论】:

  • 哇!那是附近。正是我一直在寻找的!谢谢!
猜你喜欢
  • 2011-02-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-13
  • 2018-03-31
相关资源
最近更新 更多