Replies: 12 comments 10 replies
-
Seeing the same when querying db using drizzle. Not a blocking issue for me (was just a convenient spot for me to exercise a test query) but begs the question re: limitation on middleware -- since this is server-side code path it's unclear why fails in middleware where same code block succeeds elsewhere. |
Beta Was this translation helpful? Give feedback.
-
Same issue here
|
Beta Was this translation helpful? Give feedback.
-
For anybody tracking this, I believe the issue is that nextjs middleware does not support node and this may be by design, at least for now -- see https://nextjs.org/docs/messages/node-module-in-edge-runtime |
Beta Was this translation helpful? Give feedback.
-
any update on this issue? I am getting node:crypto error for drizzle as well |
Beta Was this translation helpful? Give feedback.
-
The same error occurred when Next.js was at version 13.4.4, but upgrading to 13.4.7 fixed the issue. |
Beta Was this translation helpful? Give feedback.
-
Any solution to this in place yet? |
Beta Was this translation helpful? Give feedback.
-
I had the same issue, just a few minutes ago. How i resolve d it was use "use server" Drizzle ORM - What im using.
'use server';
import db from '..';
import { blogs, roleBlog } from '../schema';
import { errorRes } from '@/lib/utils/constants';
import { BlogProps, ResObj, err } from '@/interface'; Error: Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (Unhandled scheme). Webpack supports "data:" and "file:" URIs by default. You may need an additional plugin to handle "node:" URIs. Im assuning you are trying to make either a get or post http in a client components, if so, just put |
Beta Was this translation helpful? Give feedback.
-
I had the same problem recently and adding |
Beta Was this translation helpful? Give feedback.
-
"use server" does not work for me. In my case, I imported another package in middleware.ts and in that package it is using node:crypto. Putting "use server" in middleware.ts and even the imported package does not work. |
Beta Was this translation helpful? Give feedback.
-
same here |
Beta Was this translation helpful? Give feedback.
-
I'm encountering the same problem here, except I don't even have any middleware importing the server-only code. It's only reachable via API route and by instrumentation. Edit: I just learned that the instrumentation hook is being evaluated for client-side use? I unwired the instrumentation hook and the error went away. |
Beta Was this translation helpful? Give feedback.
-
Still not possible to use node:crypto with nextjs ? |
Beta Was this translation helpful? Give feedback.
-
Summary
Hi. I'm able to use
import { createHmac } from 'node:crypto'
inapp/api/route.ts
file but importing it in /middleware.ts file I get this error:Additional information
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions