-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
Issue type:
- question
- bug report
- feature request
- documentation issue
nestjs-config version
v1.4.5
@nestjs/common+core or other package versions
├─┬ @nestjs/[email protected]
├─┬ @nestjs/[email protected]
├─┬ @nestjs/[email protected]
├─┬ @nestjs/[email protected]
├─┬ @nestjs/[email protected]
├─┬ @nestjs/[email protected]
├─┬ @nestjs/[email protected]
Excepted behavior
ConfigService
as available in main.ts
by leveraging app.get('ConfigService')
Actual behavior or outcome (for issue)
Application fails to start with the following error.
[Nest] 80230 - 2020-02-18, 1:58:04 p.m. [ExceptionHandler] Nest could not find ConfigService element (this provider does not exist in the current context)
Error: Nest could not find ConfigService element (this provider does not exist in the current context)
[0] at ContainerScanner.getWrapperCollectionPairByHost (/Users/arvins/Sites/service/node_modules/@nestjs/core/injector/container-scanner.js:34:19)
[0] at ContainerScanner.findInstanceByToken (/Users/arvins/Sites/service/node_modules/@nestjs/core/injector/container-scanner.js:20:40)
[0] at ContainerScanner.find (/Users/arvins/Sites/service/node_modules/@nestjs/core/injector/container-scanner.js:13:21)
[0] at NestApplication.find (/Users/arvins/Sites/service/node_modules/@nestjs/core/nest-application-context.js:197:38)
[0] at NestApplication.get (/Users/arvins/Sites/service/node_modules/@nestjs/core/nest-application-context.js:43:25)
[0] at /Users/arvins/Sites/service/node_modules/@nestjs/core/nest-factory.js:111:40
[0] at Function.run (/Users/arvins/Sites/service/node_modules/@nestjs/core/errors/exceptions-zone.js:8:13)
[0] at Proxy.<anonymous> (/Users/arvins/Sites/service/node_modules/@nestjs/core/nest-factory.js:110:46)
[0] at /Users/arvins/Sites/service/dist/src/main.js:59:30
[0] at Generator.next (<anonymous>)
Replication/Example
Works perfectly fine for all node LTS versions prior to 12.16.0.
app.module.ts
import { Module } from '@nestjs/common'
import { ConfigModule, ConfigService } from 'nestjs-config'
import { HealthModule } from './health/health.module'
import * as path from 'path'
@Module({
imports: [
HealthModule,
ConfigModule.load(path.resolve(__dirname, 'config', '**/!(*.d).{ts,js}')),
],
})
export class AppModule {}
main.ts
async function bootstrap() {
const app = await NestFactory.create(AppModule)
const config = app.get('ConfigService')
await app.listen(config.get('express.port'))
}
bootstrap()
dmitrirussu, alexk4, gilzarfati, btd1337, dcyrillo and 4 more
Metadata
Metadata
Assignees
Labels
No labels