Created
October 25, 2019 14:28
-
-
Save OJezu/079398ada0d1fa4eb31230150ae456e6 to your computer and use it in GitHub Desktop.
Nest.js logger not available by default
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injectable, Logger, Module} from '@nestjs/common'; | |
import {NestFactory} from '@nestjs/core'; | |
import {NestExpressApplication} from '@nestjs/platform-express'; | |
@Injectable() | |
class TestService { | |
constructor(private readonly logger: Logger){ | |
this.logger.log("UP"); | |
} | |
} | |
@Module({ | |
providers: [ | |
TestService, | |
] | |
}) | |
class RootModule {} | |
(async () => { | |
const app = await NestFactory.create<NestExpressApplication>(RootModule); | |
await app.listen(8182); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ grep '@nestjs' yarn.lock | |
"@nestjs/cli@^6.3.0": | |
resolved "https://registry.yarnpkg.com/@nestjs/cli/-/cli-6.11.0.tgz#c15faf5425abd9ce535404c4863ff0c1b7bfb721" | |
"@nestjs/schematics" "^6.6.3" | |
"@nestjs/common@^6.0.0": | |
resolved "https://registry.yarnpkg.com/@nestjs/common/-/common-6.8.4.tgz#1aac37f154462fc833e1411883a61121fb9b8ab2" | |
"@nestjs/core@^6.8.4": | |
resolved "https://registry.yarnpkg.com/@nestjs/core/-/core-6.8.4.tgz#a583f9b4fb38ad0e663c0b478902c7b7390d8b8d" | |
"@nestjs/platform-express@^6.0.0": | |
resolved "https://registry.yarnpkg.com/@nestjs/platform-express/-/platform-express-6.8.4.tgz#8cabbe12abe587702d1bfd6aa8c95327d96abbb5" | |
"@nestjs/schematics@^6.6.3": | |
resolved "https://registry.yarnpkg.com/@nestjs/schematics/-/schematics-6.7.0.tgz#2da95fc5f1abb4a5e130bb276f74ca5321b249d2" | |
"@nestjs/swagger@^3.1.0": | |
resolved "https://registry.yarnpkg.com/@nestjs/swagger/-/swagger-3.1.0.tgz#eea2d2ef7416a588e5f122b58cd194884e265dc4" | |
"@nestjs/testing@^6.0.0": | |
resolved "https://registry.yarnpkg.com/@nestjs/testing/-/testing-6.8.4.tgz#263517a673f1b56b62c9fe7c39ff91796a95218a" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ yarn run start:dev | |
yarn run v1.19.1 | |
$ nodemon | |
[nodemon] 1.19.4 | |
[nodemon] to restart at any time, enter `rs` | |
[nodemon] watching dir(s): *.* | |
[nodemon] watching extensions: js,mjs,json | |
[nodemon] starting `ts-node -r tsconfig-paths/register src/main.ts` | |
[Nest] 15377 - 10/25/2019, 3:22:51 PM [NestFactory] Starting Nest application... | |
[Nest] 15377 - 10/25/2019, 3:22:51 PM [ExceptionHandler] Nest can't resolve dependencies of the TestService (?). Please make sure that the argument Logger at index [0] is available in the RootModule context. | |
Potential solutions: | |
- If Logger is a provider, is it part of the current RootModule? | |
- If Logger is exported from a separate @Module, is that module imported within RootModule? | |
@Module({ | |
imports: [ /* the Module containing Logger */ ] | |
}) | |
+13ms | |
Error: Nest can't resolve dependencies of the TestService (?). Please make sure that the argument Logger at index [0] is available in the RootModule context. | |
Potential solutions: | |
- If Logger is a provider, is it part of the current RootModule? | |
- If Logger is exported from a separate @Module, is that module imported within RootModule? | |
@Module({ | |
imports: [ /* the Module containing Logger */ ] | |
}) | |
at Injector.lookupComponentInExports (/home/krzysztofchrapka/gamfi/src/test-logger/node_modules/@nestjs/core/injector/injector.js:183:19) | |
at processTicksAndRejections (internal/process/task_queues.js:93:5) | |
at Injector.resolveComponentInstance (/home/krzysztofchrapka/gamfi/src/test-logger/node_modules/@nestjs/core/injector/injector.js:143:33) | |
at resolveParam (/home/krzysztofchrapka/gamfi/src/test-logger/node_modules/@nestjs/core/injector/injector.js:96:38) | |
at async Promise.all (index 0) | |
at Injector.resolveConstructorParams (/home/krzysztofchrapka/gamfi/src/test-logger/node_modules/@nestjs/core/injector/injector.js:112:27) | |
at Injector.loadInstance (/home/krzysztofchrapka/gamfi/src/test-logger/node_modules/@nestjs/core/injector/injector.js:78:9) | |
at Injector.loadProvider (/home/krzysztofchrapka/gamfi/src/test-logger/node_modules/@nestjs/core/injector/injector.js:35:9) | |
at async Promise.all (index 3) | |
at InstanceLoader.createInstancesOfProviders (/home/krzysztofchrapka/gamfi/src/test-logger/node_modules/@nestjs/core/injector/instance-loader.js:41:9) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment