首页 > 解决方案 > 如何在干净的 Nest.js 安装中忽略 React.js 源文件?

问题描述

我有一个干净的 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"
  ]
}

标签: javascriptreactjstypescriptnestjstsconfig

解决方案


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

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

推荐阅读