1

I'm working on a Next.js project (version 14.2.6) and encountering an issue related to the @node-rs/argon2 package. The build process fails with an UnhandledSchemeError for the node:crypto module. The error details are as follows: 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.

Import trace for requested module:

node:crypto
./node_modules/argon2/argon2.cjs
./auth.ts

Here’s what I’m seeing in the terminal when I run npm run dev:

⨯ node:crypto
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.

Import trace for requested module:
node:crypto
./node_modules/argon2/argon2.cjs
./auth.ts

...

⚠ Fast Refresh had to perform a full reload due to a runtime error.
GET / 500 in 48ms
GET /users 404 in 2ms
Additional Context:
Next.js Version: 14.2.6
NextAuth.js Version: 5
Argon2 Package: argon2
Node.js Version: 18.x.x
Operating System: Kali Linux
Environment Variables: Loaded via .env
Custom Webpack Configuration: None (using the default provided by Next.js)

Question:

How can I configure Webpack or Next.js to properly handle the node:crypto module when using the argon2 package? Is there a specific plugin or workaround required to address this UnhandledSchemeError?

Any help or guidance would be greatly appreciated!

What I’ve Tried:

I’ve verified that the issue is related to the node:crypto module, which is used internally by the argon2 package.

I've tried to search for a plugin or configuration that would allow Webpack to handle node: URIs but haven't been able to find a solution.

The issue persists with Fast Refresh triggering full reloads and runtime errors, leading to 500 and 404 responses during development.

1 Answer 1

0

This works for me (next v14.2.7)

/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    serverComponentsExternalPackages: ["@node-rs/argon2"],
  },
};

export default nextConfig;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.