You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Next.js集成Prisma+Tailwind+Auth.js登录功能报UnhandledSchemeError

Next.js + Prisma + Tailwind + Auth.js 构建报错:UnhandledSchemeError (node:async_hooks)

问题场景

在搭建集成了 Prisma、Tailwind CSS 和 Auth.js 的 Next.js 应用时,刚完成登录功能开发,执行构建操作就触发了以下错误:

Module build failed: UnhandledSchemeError: Reading from "node:async_hooks" 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.

排查与解决方向

由于目前公开的相关解决方案较少,整理以下可行的排查思路:

  • 核对依赖版本兼容性:确认 Next.js、Auth.js、Prisma 的版本是否匹配,部分新版本的 Auth.js 对 Node.js 内置模块的引入逻辑有调整,尝试锁定兼容版本后重新安装依赖
  • 修改 Webpack 配置处理 node: 协议:在项目根目录的 next.config.js 中添加如下配置,让 Webpack 正确识别 node: 开头的模块引入:
/** @type {import('next').NextConfig} */
const nextConfig = {
  webpack: (config) => {
    // 忽略 async_hooks 的 fallback 配置(根据实际情况调整)
    config.resolve.fallback = { ...config.resolve.fallback, async_hooks: false };
    // 处理 node: 协议的模块
    config.module.rules.push({
      test: /node:.*/,
      resolve: { fullySpecified: false },
    });
    return config;
  },
};

module.exports = nextConfig;
  • 清理缓存后重新构建:执行以下命令清理缓存和依赖,重新安装后再尝试构建:
rm -rf .next node_modules package-lock.json
npm install
npm run build

内容的提问来源于stack exchange,提问作者Salim Shamim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 05:06:01