nextjs middleware issue while calling sequelize model into it #50587
-
SummaryHey there Can any one help me out
Import trace for requested module: ./node_modules/sequelize/lib/dialects/abstract/connection-manager.js Import trace for requested module:
Additional informationNo response ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 15 replies
-
I'm also experiencing exactly the same above error |
Beta Was this translation helpful? Give feedback.
-
have you found any solution @Sanskar696 ? |
Beta Was this translation helpful? Give feedback.
-
I'm have exactly the same above error: ./node_modules/sequelize/lib/dialects/abstract/connection-manager.js Import trace for requested module: |
Beta Was this translation helpful? Give feedback.
-
I also have same error |
Beta Was this translation helpful? Give feedback.
-
If you google it:
You can try to:
Here, a thread on webpack and sequelize |
Beta Was this translation helpful? Give feedback.
-
I think that is a Next config issue. If anyone else has this problem, the solution is to add serverComponentsExternalPackages: ["sequelize"] to the next.config.js like this: /** @type {import('next').NextConfig} */ module.exports = nextConfig as documented here: https://nextjs.org/docs/app/api-reference/next-config-js/serverComponentsExternalPackages. I would appreciate it if you could provide an alternative solution or if you think this may not be the ideal solution for your project |
Beta Was this translation helpful? Give feedback.
-
@ferbragon I have same issue ONLY when I use middleware, I have tried |
Beta Was this translation helpful? Give feedback.
-
I am having the exact same error with Next 14.0.4, it happens only when running from a middleware. Server components and route handlers work well, has anyone managed to solve this? My UPDATE: Ok so the file that causes the error from Sequelize uses the |
Beta Was this translation helpful? Give feedback.
-
I had exactly the same issue with Next.js 14.x. It was on Docker which was also running MySQL container. The connection was processed through the sequelize ORM which was throwing exactly the same issue. The solution:
See the video https://youtu.be/jO8y1vHsyD0?si=kmSvKqBDBdMDqYSJ for more details. I hope this solves everyone's problem. |
Beta Was this translation helpful? Give feedback.
-
I found the solution so to help i wanted to explain it. I hope it helps within the edge-runtime you can't use nodejs runtime required modules like jsonwebtoken or sequelize which means u cant use this packages without any update coming to nextjs that gives middlewares nodejs runtime support or you can implement it in nextjs repo. But what you can do in an edge-runtime is sending fetch requests. so for example if you make a new endpoint like or whatever you prefer you can actually handle it there and do whatever you want in 1 fetch request example code
my endpoint which is /api/secure/login/route.ts
and getAdminUserWiaCredentials is
You can extend it as you prefer. Until node runtime is supported within the middleware .This is the best way i found to solve the issue. If you have another way to do it i would approaciate the share. |
Beta Was this translation helpful? Give feedback.
-
Good news everyone, Node.js Middleware support landed in Next.js 15.2 (experimental). This is now ready for testing. For any issues you run into, please open new issues so we can track and address before marking it as stable. Thank you! https://nextjs.org/blog/next-15-2#nodejs-middleware-experimental |
Beta Was this translation helpful? Give feedback.
Good news everyone, Node.js Middleware support landed in Next.js 15.2 (experimental). This is now ready for testing. For any issues you run into, please open new issues so we can track and address before marking it as stable. Thank you!
https://nextjs.org/blog/next-15-2#nodejs-middleware-experimental