语法错误:运行 Nestjs 时出现无效或意外的标记

S0A*_*1E2 2 javascript syntax-error node.js nestjs

当我运行此nestjs代码时,遇到错误:

SyntaxError: Invalid or unexpected token
Run Code Online (Sandbox Code Playgroud)

是什么原因?

import {Controller, Get, Bind, Req, Post} from '@nestjs/common';

@Controller('cats')
export class catsController {
    @Post()
    create() {
        return "this is a action 1ss"
    }
    @Get()
    @Bind(Req())
    findAll(request) {
        return "this is a action";
    }
}
Run Code Online (Sandbox Code Playgroud)

小智 12

如果遇到以下问题:

SyntaxError: Unexpected token '??='
Run Code Online (Sandbox Code Playgroud)

更新node到版本 >=16,因为该版本以下不支持上述语法