但是出了点问题。我有一个错字。你能帮我吗?
应用程序模块
export class AppModule extends NestMiddleware {
configure(consumer) {
consumer
.apply(ApiTokenCheckMiddleware)
.forRoutes({ path: '*', method: RequestMethod.ALL });
}
}
中间件
import { NestMiddleware } from "../../../node_modules/@nestjs/common/index";
const express = require("express");
const app = express();
app.use("/", (req, res, next) => {
console.log(req.headers);
});
throw err;
nest-container | ^
nest-container |
nest-container | SyntaxError: /app/src/app.module.js: Identifier
“AppModule”已经声明。 (26:13)
巢容器 |
巢容器 | 24 |提供商:[应用程序服务],
巢容器 | 25 | 25 })
巢容器 | > 26 |导出类 AppModule 扩展 NestMiddleware {
巢容器 | | ^
巢容器 | 27 | 27配置(消费者){
巢容器 | 28 | 28消费者
巢容器 | 29 | 29 .apply(ApiTokenCheckMiddleware)
代码:'BABEL_PARSE_ERROR',
巢容器 | ReasonCode: 'VarRedeclaration',
巢容器 | loc: 位置 { 行: 26, 列: 13, 索引: 874 },
巢容器 |职位:874
巢容器 |
巢容器 | Node.js v20.12.2
巢容器 | [nodemon] 应用程序崩溃 - 之前等待文件更改
开始...