@node-rs/argon2: Module parse failed: Unexpected character '�'

未关闭
#847 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
next.js, node.js, rust, typescript

调研方向

使用 node_modules 中显示的包路径复现 Next.js 14 的 server-action 导入,然后检查 src/lib/auth/index.ts 和 src/actions/login.ts,以及列出的 Windows 原生二进制文件。验证开发服务器可以在不发生解析失败的情况下加载该导入,并且 hashPassword 和 verifyPassword 仍然正常工作。

由索引模型根据 Issue 内容生成。

描述

The Problem

After installing this package using pnpm add @node-rs/argon2 my dev server crashes immediately with the following error:

Module parse failed: Unexpected character '�' (1:2)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)

Import trace for requested module:
./node_modules/.pnpm/@[email protected]/node_modules/@node-rs/argon2-win32-x64-msvc/argon2.win32-x64-msvc.node
./node_modules/.pnpm/@[email protected]/node_modules/@node-rs/argon2/index.js
./src/lib/auth/index.ts
./src/actions/login.ts

The character in question is: "U+FFFD".

I am using a Next.js 14 with server actions, where I use @node-rs/argon2 for hashing and verifying passwords on the server.

There is only two functions where I use @node-rs/argon2:

import { hash, verify } from "@node-rs/argon2"

export async function hashPassword(password: string) {
  const hashedPassword = await hash(password, {
    memoryCost: 19456,
    parallelism: 1,
    timeCost: 2,
  })
  return hashedPassword
}

export async function verifyPassword(password: string, hashedPassword: string) {
  const isValid = await verify(hashedPassword, password)
  return isValid
}

Node Version

This might be the problem since it is not listed in the support matrix.

v20.12.0

Operating System

Windows 10 x64

主要语言
Rust
星标
1.5k
派生
52
平均合并
1 天 2 小时
30 天内合并 PR
14

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

napi-rs/node-rs 的其他 Issue

查看 napi-rs/node-rs 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。