我有一个干净的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。”。

javascript - 在干净的Nest.js安装中如何忽略React.js源文件?-LMLPHP

我已经在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"
  ]
}

最佳答案

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

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

07-24 09:47
查看更多