NestJS-can';无法解析配置服务

NestJS-can';无法解析配置服务,nestjs,Nestjs,我正在使用NestJS jwt passport对用户进行身份验证。我遵循文档,这是我的应用程序模块: 从'@nestjs/common'导入{Module}; 从“./user/user.module”导入{UserModule}; 从'@nestjs/typeorm'导入{TypeOrmModule}; 从“./auth/auth.module”导入{AuthModule}; 从'@nestjs/config'导入{ConfigModule}; 从“../config/configurati

我正在使用NestJS jwt passport对用户进行身份验证。我遵循文档,这是我的应用程序模块:

从'@nestjs/common'导入{Module};
从“./user/user.module”导入{UserModule};
从'@nestjs/typeorm'导入{TypeOrmModule};
从“./auth/auth.module”导入{AuthModule};
从'@nestjs/config'导入{ConfigModule};
从“../config/configuration”导入配置;
@模块({
进口:[
ConfigModule.forRoot({
加载:[配置],
}),
TypeOrmModule.forRoot(),
用户模块,
AuthModule,
],
})
导出类AppModule{}
这是我的身份验证模块:

从'@nestjs/common'导入{Module};
从“/auth.service”导入{AuthService};
从'@nestjs/passport'导入{PassportModule};
从“../user/user.module”导入{UserModule};
从“./local.strategy”导入{LocalStrategy};
从“/jwt.strategy”导入{JwtStrategy};
从'@nestjs/config'导入{ConfigModule,ConfigService};
从'@nestjs/jwt'导入{JwtModule};
从“./auth.controller”导入{AuthController};
@模块({
进口:[
用户模块,
护照模块,
JwtModule.registerAsync({
导入:[ConfigModule],
useFactory:async(configService:configService)=>({
机密:configService.get('jwt.secret'),
标志选项:{
expiresIn:configService.get('jwt.expiresIn'),
},
}),
inject:[ConfigService],
}),
],
提供者:[AuthService、LocalStrategy、JwtStrategy],
导出:[AuthService],
控制器:[AuthController],
})
导出类AuthModule{}
每次运行
npm run start
,我都会收到以下错误消息:

Nest can't resolve dependencies of the JWT_MODULE_OPTIONS (?). Please make sure that the argument ConfigService at index [0] is available in the JwtModule context.

我已经搜索了这个问题,但仍然无法修复。有人能帮我吗?谢谢。

我为同一问题争论了几个小时,但据Chau Tran说,在使用
ConfigModule.forRoot({isGlobal:true})将
ConfigModule
设置为全局后,我所有的问题都消失了 其他人提到的一个选项是使用
isGlobal:true
设置使
ConfigModule
全局。否则,在
@nestjs中/config@0.2.3
它现在应该可以像文档中显示的那样工作。

使用
ConfigModule创建
ConfigModule
global。forRoot({isGlobal:true})
Hi,我在@ChauTran上回答了这个问题,答案也是正确的。为了让所有人都知道,这是在ConfigModule存储库上的。等待卡米尔的安息