OverwriteModelError: Cannot overwrite `xxx` model once compiled.
See original GitHub issueHi Guys. I have a problem. I understand what is going on, but I don’t know how it fixed.
I’m using mongoose as common ORM instead sequelize. It work not bad. But when HMR started, I have seen error in my console.
(node:29695) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): OverwriteModelError: Cannot overwrite
Clientmodel once compiled.
Mongoose doesn’t allow to define the model twice. When HMR tries to update server, it defines model twice.
Can you save me?😃
Issue Analytics
- State:
- Created 6 years ago
- Comments:21 (3 by maintainers)
Top Results From Across the Web
cannot overwrite model once compiled serverless
', name: 'OverwriteModelError' } It looks like it's asking Mongoose to define the same model twice, whereas if we used require both times...
Read more >How to modify existing schema in mongoose? - Stack Overflow
OverwriteModelError : Cannot overwrite `post` model once compiled. [0] at new OverwriteModelError (C:\Users\prate\PRACTISE ...
Read more >Cannot overwrite `xxx` model once compiled
OverwriteModelError : Cannot overwrite `xxx` model once compiled. CLEAN CODE 2019. 9. 5. 10:59. mongoose에서 발생하는 오류로.
Read more >stryker-mutator/stryker - Gitter
Or is mongoose called from inside the 'barcode.model.js' file ? ... gives the error: OverwriteModelError: Cannot overwrite `barcodes` model once compiled ...
Read more >Cannot overwrite `order` model once compiled._一颗小新星的 ...
解决nodejs.OverwriteModelError: Cannot overwrite order model once compiled.运行egg时出现这个错误,仔细检查报错后明白时命名model时出现了错误 ...
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 FreeTop 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
Top GitHub Comments
The way I did it is removing the model from mongoose’s models with
Then you can register the model again through HMR or anything else.
@dpblh I fixed it like this: