Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

364
Views
Why is importing bcrypt causing a "Cannot find module napi-v3/bcrypt_lib.node" error?

Using the Javascript bcrypt package, I get this server-side runtime import error only when deployed (on Vercel.com using Next.js /api routes which are AWS Lambdas under the hood):

41f80   ERROR   Error: Cannot find module '/var/task/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node'
Require stack:
- /var/task/node_modules/bcrypt/bcrypt.js
- /var/task/.next/serverless/pages/api/login.js
- /var/task/___next_launcher.js
- /var/runtime/UserFunction.js
- /var/runtime/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/var/task/node_modules/bcrypt/bcrypt.js:6:16)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/var/task/node_modules/bcrypt/bcrypt.js',
    '/var/task/.next/serverless/pages/api/login.js',
    '/var/task/___next_launcher.js',
    '/var/runtime/UserFunction.js',
    '/var/runtime/index.js'
  ]
}

I definitely npm installed it:

"bcrypt": "^5.0.1",

It works locally, but not when deployed.
I'm using the library server-side.
I've scoured the internet for hours trying to find the answer to this, but I can't find anyone who's has this exact issue.

Local node version: v14.16.0
Hosted node version: v14x

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Found the answer here: https://forum.serverless.com/t/after-making-a-deploy-i-test-the-function-and-show-this/8624/2

TLDR: Had to use bcryptjs which is written purely in Javascript. Apparently the regular bcrypt library requires some C++ dependencies that aren't gauranteed in some environments (such as AWS' node environment).

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!