Skip to content

MODULE_NOT_FOUND: bcrypt_lib.node after build on server (locally works fine) #1204

@mahamodulhasanmoon

Description

@mahamodulhasanmoon

Bug Description

After building my TypeScript Node.js app locally and deploying to my production server (Ubuntu, behind Nginx), I encounter the following runtime error when running the app:

Error: Cannot find module '/home/bunnygameshop-api/htdocs/api.bunnygameshop.com/node_modules/.pnpm/[email protected]/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node'

markdown
Copy
Edit

This does not happen locally — everything works fine before deployment.

Environment

  • bcrypt version: 5.1.1
  • Node version: [your node version here, e.g., 20.x]
  • Package manager: pnpm
  • Build tool: tsc (TypeScript)
  • Server OS: Ubuntu 22.04 LTS
  • Deployment: After pnpm install && pnpm build locally, then files pushed to server

Steps to Reproduce

  1. Install bcrypt and develop app locally.
  2. Build using TypeScript (pnpm run build)
  3. Deploy built files to server via SCP or Git
  4. Run app on server with node dist/index.js
  5. Error occurs at bcrypt require()

Expected Behavior

bcrypt should load the native bindings correctly after deployment.

Actual Behavior

MODULE_NOT_FOUND for .node file specific to bcrypt's native bindings.

Additional Info

Let me know if there's anything I should be doing differently for server builds — or if bcrypt should detect this and fail more gracefully.

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions