[ ] Regression
[ ] Bug report
[*] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Currently the error message for when an 'element' or module is not found is rather cryptic.
e.g
Nest cannot find given element (it does not exist in current context)
at NestApplicationContext.findInstanceByPrototypeOrToken (../node_modules/@nestjs/core/nest-application-context.js:71:19)
at NestApplicationContext.find (../node_modules/@nestjs/core/nest-application-context.js:38:21)
at NestApplicationContext.get (../node_modules/@nestjs/core/nest-application-context.js:32:25)
at Object.beforeAll (nodes/nodes.e2e-spec.ts:51:73)
Let Nest tell me which element or module is not found.
Just create a setup where one of the elements is never imported.
It's trivial to expose the name of the element/module:
As a more advanced solution it would be nice to get some kind of print out of the context.
Nest version: 5.1.0
Thanks for reporting @rhalff
I was unable to get an instance of my interceptor in main.ts using
app.select(SharedModule).get(SessionManagerInterceptor);
Error:
(node:15016) UnhandledPromiseRejectionWarning: Error: Nest cannot find given element (it does not exist in current context)
at NestApplicationContext.findInstanceByPrototypeOrToken (E:xamphtdocswwwloanApploan-apinode_modules@nestjscorenest-application-context.js:70:19)
at NestApplicationContext.find (E:xamphtdocswwwloanApploan-apinode_modules@nestjscorenest-application-context.js:38:21)
at NestApplicationContext.get (E:xamphtdocswwwloanApploan-apinode_modules@nestjscorenest-application-context.js:32:25)
at bootstrap (E:xamphtdocswwwloanApploan-apisrcmain.ts:16:30)
at
(node:15016) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a
promise which was not handled with .catch(). (rejection id: 1)
(node:15016) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a
non-zero exit code.
Nest version: 5.1.0
Any Solution to this?
Fixed by #1143
Fixed in 5.4.0
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Fixed by #1143