-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OverwriteModelError: Cannot overwrite User
model once compiled.
#53
Comments
On Windows, if we try to open a User.js or user.js file, both will point to the same location (which is what happened here). However, nodejs manages the modules themselves in a case-sensitive manner. So if we do: require ('./ User') and require ('./ User'), nodejs will try to register 2x. What duplicates User schema registration in mongoose. On Linux / Mac this would not happen, because well before this error popped up, the node would scream saying that the module User.js does not exist. And it would be much simpler to find the error. //Fix for more info refer here: https://www.devpleno.com/corrigindo-o-erro-cannot-overwrite-model-model-once-compiled-no-mongoose/ |
File name is case sensitive .
|
Thanks Sir for the solution.. |
throw new _mongoose.Error.OverwriteModelError(name);
^
OverwriteModelError: Cannot overwrite
User
model once compiled.The text was updated successfully, but these errors were encountered: