leepowelldev / mongoose-validator

Validators for mongoose models utilising validator.js
MIT License
379 stars 43 forks source link

Module not found: Error: Can't resolve './default-error-messages' #45

Closed eran10 closed 6 years ago

eran10 commented 6 years ago

ERROR in ./node_modules/mongoose-validator/lib/mongoose-validator.js Module not found: Error: Can't resolve './default-error-messages'

you must add .json to your file so it will work instead of const defaultErrorMessages = require('./default-error-messages') use this const defaultErrorMessages = require('./default-error-messages.json')

leepowelldev commented 6 years ago

Node should resolve '.json' files without the extension. Which version of Node are you using?

eran10 commented 6 years ago

latest node (8.9.4), when i added myself .json it only worked (windows)

leepowelldev commented 6 years ago

Hmm, not sure what is going on, this is from the Node documentation about how require resolves file name:

If the exact filename is not found, then Node.js will attempt to load the required filename with the added extensions: .js, .json, and finally .node.

I would suggest this might be an issue with your setup as no one else is reporting this issue. Have you got repo or anything so I might able to see what's happening?

eran10 commented 6 years ago

no its private, when i change to .json it work as expected so i will fork this repo.. although i do believe that if you will put .json it will be even clearer to understand the line but as you want dear

leepowelldev commented 6 years ago

OK, sorry I can't help much more ... I'm happy to release a patch update if you can wait.

leepowelldev commented 6 years ago

v2.0.1 released with .json extension for you.

eran10 commented 6 years ago

thanks!