Using bcrypt, 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
没有评论:
发表评论