Node.js使用argon2报错GLIBC_2.25 not found的解决方法咨询
解决Node.js中argon2依赖GLIBC_2.25缺失的问题
可行解决方案:
1. 降级argon2到兼容低版本GLIBC的预编译版本
先卸载当前安装的argon2:
npm uninstall argon2
安装对GLIBC版本要求较低的argon2版本(推荐0.28.x系列,该版本预编译包适配旧系统):
npm install argon2@0.28.5
如果该版本仍有问题,可以尝试测试0.28.x范围内的其他版本。
2. 本地编译argon2适配当前系统
若系统具备编译环境,可通过本地编译生成适配当前GLIBC的argon2二进制文件:
- 安装编译依赖(以CentOS/RHEL系统为例):
yum install gcc-c++ make python3
- 卸载现有argon2后,强制本地编译安装:
npm uninstall argon2 npm install argon2 --build-from-source
编译完成后,生成的argon2.node会适配当前系统的GLIBC版本,解决依赖问题。
3. 替换为纯JS实现的加密库
如果上述方法无法生效,可改用纯JavaScript编写的密码哈希库(无需编译,不依赖系统GLIBC),比如bcryptjs:
- 卸载argon2并安装bcryptjs:
npm uninstall argon2 npm install bcryptjs
- 修改代码中的加密逻辑,示例如下:
原argon2调用:
const argon2 = require('argon2'); const hash = await argon2.hash('your-password');
替换为bcryptjs调用:
const bcrypt = require('bcryptjs'); const hash = await bcrypt.hash('your-password', 10);
内容的提问来源于stack exchange,提问作者rizky2609
相关产品推荐
相关产品推荐

