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

Build Failure: bcrypt Module Not Found During Production Build #1034

Open
ibrahimkonuk opened this issue Mar 26, 2025 · 1 comment
Open

Build Failure: bcrypt Module Not Found During Production Build #1034

ibrahimkonuk opened this issue Mar 26, 2025 · 1 comment

Comments

@ibrahimkonuk
Copy link

Hi Team,

I'm encountering a build failure while following the Next.js dashboard tutorial (https://nextjs.org/learn/dashboard-app/getting-started). The issue occurs during the production build process (pnpm build).

Description of the Issue

The build process fails with a "Module Not Found" error related to the bcrypt package. Specifically, the error message indicates that the native bindings for bcrypt cannot be located.

nextjs-dashboard % pnpm build
> @ build /Users/.../nextjs-dashboard
> next build

   ▲ Next.js 15.1.6

   Creating an optimized production build ...
 ✓ Compiled successfully
 ✓ Linting and checking validity of types    
   Collecting page data  ..[Error: Cannot find module '.../nextjs-dashboard/node_modules/.pnpm/[email protected]/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node'
Require stack:
- .../nextjs-dashboard/node_modules/.pnpm/[email protected]/node_modules/bcrypt/bcrypt.js
- .../nextjs-dashboard/.next/server/app/seed/route.js
- .../nextjs-dashboard/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/require.js
- .../nextjs-dashboard/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/load-components.js
- .../nextjs-dashboard/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/build/utils.js
- .../nextjs-dashboard/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/build/worker.js
- .../nextjs-dashboard/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/jest-worker/processChild.js] {
  code: 'MODULE_NOT_FOUND',
  requireStack: [Array]
}

> Build error occurred
[Error: Failed to collect page data for /seed] { type: 'Error' }
 ELIFECYCLE  Command failed with exit code 1.

Context

This issue occurs during the pnpm build command, specifically when Next.js is attempting to collect page data. The error prevents a production build from being created.

Environment

  • Next.js version: 15.1.6 (as per the tutorial)
  • pnpm version: 10.6.5
  • Node.js version: v20.18.0
  • Package Manager: pnpm

Additional Information

During pnpm install, the following warning was also displayed:

Warning
Ignored build scripts: bcrypt, sharp.
Run "pnpm approve-builds" to pick which dependencies should
be allowed to run scripts.

Possible Root Cause

The bcrypt package relies on native bindings, which may not be correctly compiled or located during the build process, especially in a Next.js environment. The warning about ignored build scripts could be related.

Suggested Solution/Workaround

A workaround that resolves the issue is to replace bcrypt with bcryptjs. bcryptjs is a pure JavaScript implementation and does not require native bindings.

pnpm remove bcrypt
pnpm add bcryptjs

Impact

This build failure prevents users from completing the Next.js dashboard tutorial and deploying a production-ready application.

Thank you for your attention to this matter. I hope this information is helpful in resolving the issue.

@Joysca
Copy link

Joysca commented Mar 31, 2025

Another option works, delete the project in the Vercel and import the project again and add the environment variable of postgreSql

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