Getting `Error: Cannot find module '@node-rs/argon2-linux-arm64-gnu'` and `'./argon2.linux-arm64-gnu.node'` error

Đang mở
#861 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
aws, docker, next.js, node.js
Lĩnh vực
backend, cloud, devops

Hướng nghiên cứu

Bắt đầu với logic tải native trong node_modules/@node-rs/argon2/index.js và entry .next/server/app/(main)/(auth)/signin/page.js đã triển khai được hiển thị trong stack trace. Tái hiện lỗi với các thiết lập triển khai Node.js, Next.js, Docker và AWS được liệt kê; hoàn tất khi API hashing và verification đã triển khai tải được native binding Linux ARM64 cần thiết mà không gặp MODULE_NOT_FOUND.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Here are some of the dependencies I use.

  • Next.js: ^14.2.4,
  • @node-rs/argon2: ^1.8.3
  • node: 18.17.1 and 20.12.2 (tried both)
  • macOS M2 Pro, Sonoma 14.2.1

Build / deploy using both AWS Cloudfront or Docker container

I switched over to using node-rs/argon2 package since the oslo/password package was causing dev error.
If I use node-rs/argon2 package:

import { hash, verify } from '@node-rs/argon2'
...
export async function encryptPassword(password: string): Promise<string> {
  return await hash(password, {
    memoryCost: 19456,
    timeCost: 2,
    outputLen: 32,
    parallelism: 1,
  })
}

export async function verifyPassword(
  password: string,
  hashedPassword: string,
): Promise<boolean> {
  return await verify(hashedPassword, password, {
    memoryCost: 19456,
    timeCost: 2,
    outputLen: 32,
    parallelism: 1,
  })
}
Error

After building Next.js and deploying it either using AWS Cloudfront or just containerize the app with Docker and running it, the api the handles the hashing and verifying fails with the following error:

Error: Failed to load native binding
    at Object.<anonymous> (/var/task/node_modules/.pnpm/@[email protected]/node_modules/@node-rs/argon2/index.js:359:11)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
    at Module.load (node:internal/modules/cjs/loader:1203:32)
    at Module._load (node:internal/modules/cjs/loader:1019:12)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at mod.require (/var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/require-hook.js:65:28)
    at require (node:internal/modules/helpers:177:18)
    at 82406 (/var/task/.next/server/app/(main)/(auth)/signin/page.js:1:81)
    at t (/var/task/.next/server/webpack-runtime.js:1:128) {
  digest: '903678548',
  [cause]: [
    Error: Cannot find module './argon2.linux-arm64-gnu.node'
    Require stack:
    - /var/task/node_modules/.pnpm/@[email protected]/node_modules/@node-rs/argon2/index.js
    - /var/task/.next/server/app/(main)/(auth)/signin/page.js
    - /var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/require.js
    - /var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/next-server.js
        at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
        at /var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/require-hook.js:55:36
        at Module._load (node:internal/modules/cjs/loader:981:27)
        at Module.require (node:internal/modules/cjs/loader:1231:19)
        at mod.require (/var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/require-hook.js:65:28)
        at require (node:internal/modules/helpers:177:18)
        at requireNative (/var/task/node_modules/.pnpm/@[email protected]/node_modules/@node-rs/argon2/index.js:237:16)
        at Object.<anonymous> (/var/task/node_modules/.pnpm/@[email protected]/node_modules/@node-rs/argon2/index.js:332:17)
        at Module._compile (node:internal/modules/cjs/loader:1364:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1422:10) {
      code: 'MODULE_NOT_FOUND',
      requireStack: [Array]
    },
    Error: Cannot find module '@node-rs/argon2-linux-arm64-gnu'
    Require stack:
    - /var/task/node_modules/.pnpm/@[email protected]/node_modules/@node-rs/argon2/index.js
    - /var/task/.next/server/app/(main)/(auth)/signin/page.js
    - /var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/require.js
    - /var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/next-server.js
        at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
        at /var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/require-hook.js:55:36
        at Module._load (node:internal/modules/cjs/loader:981:27)
        at Module.require (node:internal/modules/cjs/loader:1231:19)
        at mod.require (/var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/require-hook.js:65:28)
        at require (node:internal/modules/helpers:177:18)
        at requireNative (/var/task/node_modules/.pnpm/@[email protected]/node_modules/@node-rs/argon2/index.js:242:16)
        at Object.<anonymous> (/var/task/node_modules/.pnpm/@[email protected]/node_modules/@node-rs/argon2/index.js:332:17)
        at Module._compile (node:internal/modules/cjs/loader:1364:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1422:10) {
      code: 'MODULE_NOT_FOUND',
      requireStack: [Array]
    }
  ]
}

Can't figure out why this is. Has there been any hacks or fixes for this issue?

Ngôn ngữ chính
Rust
Star
1.5k
Fork
52
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của napi-rs/node-rs

Tất cả issue của napi-rs/node-rs

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.