ranisalt / node-argon2

Node.js bindings for Argon2 hashing algorithm
https://www.npmjs.com/package/argon2
MIT License
1.87k stars 92 forks source link

ReferenceError: require is not defined #404

Closed pulgueta closed 1 month ago

pulgueta commented 4 months ago

Welcome to the issues section if it's your first time!

Before creating an issue, please be sure to:

Steps to reproduce

I am using Next.js, I had a project using argon2 which worked just fine, but now in a new project I try to use argon2 but fails. No edge pages or route handlers are set.

  1. Install argon2 with bun add argon2
  2. Run local development server bun dev
  3. Fails

Expected behaviour

It should let the page load even if the function running the package is not being used and hash the password.

Actual behaviour

Page loads, shows a 200 OK status in console but throws this error: image

Environment

Operating system:

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 16304
  Available CPU cores: 6
Binaries:
  Node: 20.12.2
  npm: N/A
  Yarn: N/A
  pnpm: 9.0.1
Relevant Packages:
  next: 14.2.3 // Latest available version is detected (14.2.3).
  eslint-config-next: 14.2.3
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.4.5
Next.js Config:
  output: N/A

Node version: 20.11.0

Bun version: 1.1.7

Compiler version:

ranisalt commented 4 months ago

From the stack trace I suppose that somehow you have a call to argon2 in your frontend, rather than in your backend, which does not work. Is that the case?