TypeError: Cannot read property ‘sync’ of undefined
While working with sequelize for the first time, I encountered this error, and it was annoying because I had no idea where I was going wrong. In this post am going to share the possibility of the “TypeError: Cannot read property ‘sync’ of undefined”.
Few reason why you are getting the ‘sync’ of undefined error below
- The error above can be caused when you type exports in your index.js file incorrectly like in the snippet below.
2. Overwriting the exports variable with the Sequelize variable can also cause the above ‘sync’error.
3. When your model.exports is not included in your index.js file or it is commented out, this can also cause the ‘sync’ of undefined error.
Working with a new software is interesting and amusing, but sometimes it becomes tiring when small errors are difficult to trace when you know you are on the right track. Well hopefully this helps when you encounter this kind of error. Happy coding.