Search code examples
javascriptreactjstypescriptnestjstsconfig

How to ignore React.js source files in a clean Nest.js installation?


I have a clean Nest.js installation and a folder called "client" with create-react-app clean installation in it.

Let's assume the project structure is:

./
  ...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

I'm trying to run npm start:dev inside the project root folder to make Nest.js compile all the files, but it keeps complaining "Cannot use JSX unless the '--jsx' flag is provided.".

The error message

I've added the "client" folder to "exclude" block inside the tsconfig.json of Nest.js installation. And I still keep having this error!

What am I doing wrong? How to completely ignore the client files for the Nest.js compilation script?

The tsconfig.json contents:

{
  "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"
  ]
}

Solution

  • You have to exclude the folder in tsconfig.build.json too

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