Next.js Discord

Discord Forum

Error: Cannot find module 'node:crypto'

Unanswered
Silver Marten posted this in #help-forum
Open in Discord
Avatar
Silver MartenOP
I have recently migrated to next 15.0.2 version and I started seeing this error.

Any suggestions on how I can fix it?
Error: Cannot find module 'node:crypto': Unsupported external type Url for commonjs reference

7 Replies

Avatar
Silver MartenOP
Here is the error trace
Error: Cannot find module 'node:crypto': Unsupported external type Url for commonjs reference
    at <unknown> (file:///Users/johnversus/Work/master-calculator/.next/server/edge/chunks/0e041_@workos-inc_node_lib_bd1d6a._.js:92:15)
    at [project]/node_modules/.pnpm/@workos-inc+node@7.14.0/node_modules/@workos-inc/node/lib/common/crypto/node-crypto-provider.js [middleware] (ecmascript) (file:///Users/johnversus/Work/master-calculator/.next/server/edge/chunks/0e041_@workos-inc_node_lib_bd1d6a._.js:95:3)
    at <unknown> (file:///Users/johnversus/Work/master-calculator/.next/server/edge/chunks/edge-wrapper_b19704.js:693:27)
    at runModuleExecutionHooks (file:///Users/johnversus/Work/master-calculator/.next/server/edge/chunks/edge-wrapper_b19704.js:738:9)
    at instantiateModule (file:///Users/johnversus/Work/master-calculator/.next/server/edge/chunks/edge-wrapper_b19704.js:691:9)
    at getOrInstantiateModuleFromParent (file:///Users/johnversus/Work/master-calculator/.next/server/edge/chunks/edge-wrapper_b19704.js:624:12)
    at commonJsRequire (file:///Users/johnversus/Work/master-calculator/.next/server/edge/chunks/edge-wrapper_b19704.js:157:20)
    at [project]/node_modules/.pnpm/@workos-inc+node@7.14.0/node_modules/@workos-inc/node/lib/index.js [middleware] (ecmascript) (file:///Users/johnversus/Work/master-calculator/.next/server/edge/chunks/0e041_@workos-inc_node_lib_bd1d6a._.js:5320:32)
    at <unknown> (file:///Users/johnversus/Work/master-calculator/.next/server/edge/chunks/edge-wrapper_b19704.js:693:27)
    at runModuleExecutionHooks (file:///Users/johnversus/Work/master-calculator/.next/server/edge/chunks/edge-wrapper_b19704.js:738:9)
Avatar
node crypto is not available in middleware
Avatar
Silver MartenOP
How can I fix it?
Avatar
depends on what u trying to achieve
Avatar
Silver MartenOP
The only import I have in my middleware for @workos-inc/authkit-nextjs. I guess the error is coming from this package?
import { authkitMiddleware } from "@workos-inc/authkit-nextjs";
Avatar
It is using crypto, which middleware doesn't support