vercel / next.js

The React Framework
https://nextjs.org
MIT License
122.92k stars 26.28k forks source link

Module not found: Can't resolve '@node-rs/argon2-wasm32-wasi' #65996

Open pulgueta opened 1 month ago

pulgueta commented 1 month ago

Link to the code that reproduces this issue

https://github.com/pulgueta/OSS-Interviewer

To Reproduce

  1. Install dependencies using bun install
  2. Add mock env variables
  3. Run local dev server using bun dev

Current vs. Expected behavior

Current behavior: image

Expected behavior: Should just work

Provide environment information

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
  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

Which area(s) are affected? (Select all that apply)

Runtime

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

My next.config.mjs:

import { fileURLToPath } from 'node:url';

import createJITI from 'jiti';

const jiti = createJITI(fileURLToPath(import.meta.url));

jiti('./env.server.ts');

/** @type {import('next').NextConfig} */
const nextConfig = {
    poweredByHeader: false,
    reactStrictMode: true,
    logging: {
        fetches: {
            fullUrl: true,
        },
    },
    experimental: {
        serverComponentsExternalPackages: ["@node-rs/argon2"],
        staleTimes: {
            dynamic: 0,
        }
    },
};

export default nextConfig;
drithh commented 1 month ago

have you fixed it?

drithh commented 1 month ago

i fixed it, its actually a human error

Module32 commented 1 week ago

@drithh Do you mind sharing how you solved it?

drithh commented 1 week ago

In my case, I forgot to add the use-server or server-only directives to my login mechanism. I had put the use-client directive in the login form and imported the login mechanism, which made Next.js think the login mechanism should run in the browser. However, it should run on the server.