metatype is not a constructor
See original GitHub issueI’m submitting a…
[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
when i set a string value to provide property. it’s ok
providers: [
{ provide: 'PERSON_REPOSITORY', useClass: PersonRepository },
],
but when i set a const instead of string value 😐
import { PERSON_REPOSITORY } from '../../common/data';
.
.
.
providers: [
{ provide: PERSON_REPOSITORY, useClass: PersonRepository },
],
.
.
.
[Nest] 11352 - 2019-2-17 17:47:26 [NestFactory] Starting Nest application...
[Nest] 11352 - 2019-2-17 17:47:26 [ExceptionHandler] metatype is not a constructor +159ms
TypeError: metatype is not a constructor
at resolveConstructorParams (E:\My Project\fennec\fennec.lord\node_modules\@nestjs\core\injector\injector.js:65:84)
at Injector.resolveConstructorParams (E:\My Project\fennec\fennec.lord\node_modules\@nestjs\core\injector\injector.js:99:30)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
at Object.<anonymous> (E:\My Project\fennec\fennec.lord\node_modules\ts-node\src\_bin.ts:182:12)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:266:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
[Nest] 11352 - 2019-2-17 17:47:26 [InstanceLoader] AppModule dependencies initialized +4ms
[Nest] 11352 - 2019-2-17 17:47:26 [InstanceLoader] MongooseModule dependencies initialized +1ms
[Nest] 11352 - 2019-2-17 17:47:26 [InstanceLoader] PassportModule dependencies initialized +1ms
1: 00007FF76D620205
2: 00007FF76D5FA176
3: 00007FF76D58AB99
4: 00007FF76DC34102
5: 00007FF76DC3556D
6: 00007FF76DC345F9
7: 00007FF76DC344DB
8: 00000019B8E841C1
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! fennec.lord@1.0.0 start: `ts-node -r tsconfig-paths/register src/main.ts`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the fennec.lord@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\vahid\AppData\Roaming\npm-cache\_logs\2019-02-17T14_17_26_767Z-debug.log
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
metatype is not a constructor · Issue #5685 · nestjs/nest
Bug Report metatype is not a constructor Current behavior Input Code import { ShareModule } from '@app/share'; import { Module } from ...
Read more >Error: metatype is not a constructor when using instance of ...
It does not throws error but while building this is not recognized. use the full file path and it will most probably solve...
Read more >TypeError: "x" is not a constructor - JavaScript - MDN Web Docs
The JavaScript exception "is not a constructor" occurs when there was an attempt to use an object or a variable as a constructor,...
Read more >[Nest.js] ERROR [ExceptionHandler] metatype is not a ...
nest.js 서버 실행 시 TypeError: metatype is not a constructor 에러가 발생했다. 어디서 발생한 문제인지 도저히 알 수 없어서 매우 난감했다.
Read more >Use Node.js Dependencies In Nestjs? How?
Internally in NestJS we do it all the time. See an example here in nestjs/typeorm and here. [ExceptionHandler] metatype is not a constructor....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you kamil Of course, by doing this in the minimal repository, the problem is solved, but unfortunately, the actual project still has the same error message. So after reviewing the files that I deleted from the project, I was surprised to find that the problem was solved by renaming the model folder to any other name. I really did not notice the relevance of the model folder with PERSON_REPOSITORY!
change to: