首页 > 技术文章 > Warning: no saslprep library specified. Passwords will not be sanitized

honeynm 2020-10-06 16:12 原文

Warning: no saslprep library specified. Passwords will not be sanitized

在 nodejs 中使用密码连接 mongodb 时,会报 warning:

Warning: no saslprep library specified. Passwords will not be sanitized
  • 1

在 mongodb 的依赖里 node_modules/mongodb/lib/core/auth/scram.js 发现有以下代码:

12: let saslprep;
13: try {
14:   saslprep = require('saslprep');
15: } catch (e) {
16:   // don't do anything;
17: }
     ...
264:if (!saslprep) {
265:  console.warn('Warning: no saslprep library specified. Passwords will not be sanitized');
267:}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

可见如果没有安装 saslprep 导致了 warning。所以解决方法就是:

npm install saslprep --save

推荐阅读