【问题标题】:NestJS Logger: Can't set logger types in main.tsNestJS 记录器:无法在 main.ts 中设置记录器类型
【发布时间】:2020-02-05 05:24:35
【问题描述】:

当尝试在main.ts 中设置记录器类型时,就像在in the docs 中显示的那样:

const app = await NestFactory.create(ApplicationModule, {
  logger: ['error', 'warn'],
});
await app.listen(3000);

VS 代码没有给我LogLevel[] 的选项,只有booleanLoggerService,所以日志记录不起作用。我正在使用:

"@nestjs/common": "^6.8.2",
"@nestjs/core": "^6.8.2",
"@nestjs/jwt": "^6.1.1",
"@nestjs/passport": "^6.1.0",
"@nestjs/platform-express": "^6.8.2",
"@nestjs/swagger": "^3.1.0",
"@nestjs/typeorm": "^6.2.0",

【问题讨论】:

  • 对我来说这行得通。您能否尝试删除您的 node_modules 并重新运行 npm install 以确保您安装了正确的依赖项?
  • @KimKern 谢谢这是问题

标签: javascript node.js typescript npm nestjs


【解决方案1】:

虽然它们已经在您的package.json 中声明,但未安装最新的依赖项。为了确保您确实安装了想要的版本,请删除您的 node_modules 文件夹并重新运行 npm install

【讨论】:

    猜你喜欢
    • 2021-06-25
    • 2022-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-26
    • 1970-01-01
    • 2021-12-30
    • 2012-02-14
    相关资源
    最近更新 更多