在 Next.js 中找不到@node-rs/argon2 模块

问题描述 投票:0回答:1

我正在尝试使用 lucia 实现用户名和密码登录,就像在 lucia 教程中一样,我使用 @node-rs/argon2 来哈希密码,但我收到此错误:

Error: The specified module could not be found. ?\D:\Coding\social_app\node_modules@node-rs\argon2-win32-x64-msvc\argon2.win32-x64-msvc.node

enter image description here

我的 next.config.mgs

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

export default nextConfig;

我尝试重新安装所有依赖项,将节点和 npm 更新到最新版本,但没有帮助。 Next.js 版本 15.0.0-rc.0.

node.js next.js
1个回答
0
投票

这对我有用(下一个 v14.2.7)

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

export default nextConfig;
© www.soinside.com 2019 - 2024. All rights reserved.