Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vercel deployment errors out when installing bcrypt

Whenever vercel trys to build my webpage it has an error:

npm ERR! code 1
npm ERR! path /vercel/path0/node_modules/bcrypt
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)
npm ERR! node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node)
npm ERR! A complete log of this run can be found in:
npm ERR!     /vercel/.npm/_logs/2023-05-27T05_36_03_200Z-debug-0.log
Error: Command "npm install" exited with 1
BUILD_UTILS_SPAWN_1: Command "npm install" exited with 1

Can't seem to find an answer on this one. I did change the build to npm start like it is in my package.json I use npm node src/app.js. If I don't use that then it will build it but my request just error out.

Edit: So I was able to switch to bcryptjs and that fixed that issue I'm still getting errors for the GLIBC from node now.

like image 954
David Young Avatar asked Apr 14 '26 23:04

David Young


2 Answers

Unlike most packages you install from npm/yarn, bcrypt often has errors when deploying to cloud environments because it's precompiled.

You require either GLIBC_2.27 or GLIBC_2.28 in your deployment environment... I haven't done this before with Vercel, but I'll give you a solution I've tried on other platforms.

Use Prebuilt Binaries. For NodeJS modules that have native code (like bcrypt) there are prebuilt binaries available. These binaries are compiled with older versions of GLIBC. Since they're backward compatible, they should work in most production environments. To use them, you might need to adjust your npm install command to something like this:

npm install bcrypt --build-from-source

Alternatively (easier but hackier), you can remove node_modules/bcrypt from your .gitignore file to push them to the server using whichever build you have locally. This is fine for independent projects. However, a more permanent solution is preferred when working on an actual application for an organization or with a small team.

like image 114
Viraj Shah Avatar answered Apr 22 '26 21:04

Viraj Shah


For me, I was getting this same error because I was declaring node itself as a dependency in my package.json file. This is not needed.

In package.json:

"dependencies": {
    "node": "^20.7.0",
  }

You want to remove the "node" line. After doing that, I was able to deploy to Vercel without getting this error.

like image 29
mikestarace Avatar answered Apr 22 '26 22:04

mikestarace



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!