title: Why is importing bcrypt causing a "Cannot find module napi-v3/bcrypt_lib.node" error?
body: <p>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):</p>
  <pre><code>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.&lt;anonymous&gt; (/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'
    ]
  }
  </code></pre>
  <p>I definitely npm installed it:</p>
  <pre><code>&quot;bcrypt&quot;: &quot;^5.0.1&quot;,
  </code></pre>
  <p>It works locally, but not when deployed.<br />
  I'm using the library server-side.<br />
  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.</p>
  <p>Local node version: v14.16.0<br />
  Hosted node version: v14x</p>