Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
holahoon opened this issue Jul 20, 2024 · 1 comment

Comments

@holahoon
Copy link

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/@node-rs+argon2@1.8.3/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/next@14.2.5_@babel+core@7.24.9_react-dom@18.3.1_react@18.3.1/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/@node-rs+argon2@1.8.3/node_modules/@node-rs/argon2/index.js
    - /var/task/.next/server/app/(main)/(auth)/signin/page.js
    - /var/task/node_modules/.pnpm/next@14.2.5_@babel+core@7.24.9_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/server/require.js
    - /var/task/node_modules/.pnpm/next@14.2.5_@babel+core@7.24.9_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/server/next-server.js
        at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
        at /var/task/node_modules/.pnpm/next@14.2.5_@babel+core@7.24.9_react-dom@18.3.1_react@18.3.1/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/next@14.2.5_@babel+core@7.24.9_react-dom@18.3.1_react@18.3.1/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/@node-rs+argon2@1.8.3/node_modules/@node-rs/argon2/index.js:237:16)
        at Object.<anonymous> (/var/task/node_modules/.pnpm/@node-rs+argon2@1.8.3/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/@node-rs+argon2@1.8.3/node_modules/@node-rs/argon2/index.js
    - /var/task/.next/server/app/(main)/(auth)/signin/page.js
    - /var/task/node_modules/.pnpm/next@14.2.5_@babel+core@7.24.9_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/server/require.js
    - /var/task/node_modules/.pnpm/next@14.2.5_@babel+core@7.24.9_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/server/next-server.js
        at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
        at /var/task/node_modules/.pnpm/next@14.2.5_@babel+core@7.24.9_react-dom@18.3.1_react@18.3.1/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/next@14.2.5_@babel+core@7.24.9_react-dom@18.3.1_react@18.3.1/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/@node-rs+argon2@1.8.3/node_modules/@node-rs/argon2/index.js:242:16)
        at Object.<anonymous> (/var/task/node_modules/.pnpm/@node-rs+argon2@1.8.3/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?

@Brooooooklyn
Copy link
Member

@holahoon use pnpm --force to install all platform dependencies on Vercel build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants