parsecer
parsecer

Reputation: 5106

Webstorm: Can't run simple nestjs app. Error: Experimental support for decorators is a feature that is subject to change in a future release

I created a default nestjs project using

nest new my-nestjs-01

command from this tutorial. I configured Webstorm to run typescript files like this:

enter image description here

So now when I open a .ts file in editor and click

enter image description here

at the top, the current opened file gets executed.

However when I execute main.ts I get this error:

 Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.

This is the default project code that has been generated for me with the above nest command. I tried adding additional options to tsconfig.json to fix the error, but it didn't help:

tsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "js/ts.implicitProjectConfig.experimentalDecorators":true,
    "suppressImplicitAnyIndexErrors": true

  },
  "files": [
    "src/main.ts",
    "src/app.service.ts"
  ],
  "include": [
    "src/**/*.d.ts"
  ]
}

main.ts:

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  await app.listen(3000);
}
bootstrap();

app.module.ts:

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
  imports: [],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {} // <-- error here

How do I fix it? Any help is appreciated.

EDIT:

Solution from suggested answer:

Pasting my configuration from tsconfig.json into the tsconfig.spec.json file fixed the issue.

did not solve my problem.

Upvotes: 1

Views: 2124

Answers (1)

Arthur Zennig
Arthur Zennig

Reputation: 2194

My catch with WebStorm x NestJs RUN CONFIGURATION, was simply that I was not point to the correct JavaScript file (needs to point to the main.js file transcripted). For the default installation of NestJs, this main.js file is located in the ~/dist folder; In my case, image below shows a working config: enter image description here

Upvotes: 0

Related Questions