NestJS authGuard剂量管理器有效

时间:2018-10-21 12:57:55

标签: javascript express authentication nestjs

我正在实现@nestjs/passport('jwt')并使用@UseGuards(AuthGuard())装饰器(就像在说明中一样),但出现以下异常:

  

common_1。可选的不是函数

有人知道可能是什么问题吗?

依赖项:

  

“ @ nestjs / common”:“ ^ 5.0.0”,

"@nestjs/core": "^5.0.0",
"@nestjs/cqrs": "^5.1.1",
"@nestjs/jwt": "^0.2.0",
"@nestjs/mongoose": "^5.1.0",
"@nestjs/passport": "^5.1.0",
"@nestjs/swagger": "^2.4.4",
"@nestjs/typeorm": "^5.2.2",
"automapper-ts": "^1.9.0",
"config": "^2.0.1",
"fastify-formbody": "^2.0.0",
"lodash": "^4.17.10",
"mongodb": "^3.1.6",
"mongoose": "^5.2.9",
"mysql": "^2.16.0",
"nestjs-rmq": "^0.1.3",
"nestjs-typegoose": "^5.0.1",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"reflect-metadata": "^0.1.12",
"rxjs": "^6.0.0",
"typegoose": "^5.4.0",
"typeorm": "^0.2.7",
"typescript": "^2.6.2",

4 个答案:

答案 0 :(得分:2)

依赖关系已过时。尝试运行npm update

答案 1 :(得分:0)

也许我不太了解这个问题,但是要使用守护程序,您可以给一个守护程序实例或一个类,然后让其嵌套创建该实例,守护程序不是一个函数*

@UseGuards(AuthGuard())应该是: @UseGuards(新的AuthGuard()) 要么 @UseGuards(AuthGuard)

答案 2 :(得分:0)

您似乎使用了旧的依赖项。

安装npm g npm检查

运行npm-check -u

https://www.npmjs.com/package/npm-check

答案 3 :(得分:0)

依赖问题

试试这个:

$ sudo npm install -g npm-check

$ npm-check -u