简体   繁体   English

使用 MongoClient.connect() 时的 saslprep 警告

[英]saslprep warning when using MongoClient.connect()

I'm writing a NodeJS/express API and am facing the following warning when connecting to mongo server:我正在编写一个 NodeJS/express API 并且在连接到 mongo 服务器时面临以下警告:

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

Found no mention of this warning in documentation or github/google - is that OS (linux) library missing, or node package?在文档或 github/google 中没有发现此警告的提及 - 是缺少操作系统(linux)库还是节点包?

This is the connection code sample:这是连接代码示例:

const client = await MongoClient.connect(`mongodb://${auth[0]}:${auth[1]}@${url}/admin`, {
    useNewUrlParser: true
});
this.db = client.db(database);

How can I get rid of it?我怎样才能摆脱它?

Additional information:附加信息:

Mongodb server: docker mongo:latest, resolved to 4.0.4 as of now Mongodb 服务器:docker mongo:latest,截至目前已解析为 4.0.4

mongodb library: 3.1.9 mongodb 库:3.1.9

Please use this command in your app.请在您的应用程序中使用此命令。 It worked for me.它对我有用。 Hope it help you.希望对你有帮助。

npm install saslprep --save

Just install the saslprep package and the warning will go away. 只需安装saslprep软件包,警告就会消失。

The mongodb package looks for the saslprep package, but works without it; mongodb包寻找saslprep包,但没有它; it's an optional dependency. 这是一个可选的依赖。

If you look in the mongodb source: 如果你查看mongodb源:

let saslprep;
try {
  saslprep = require('saslprep');
} catch (e) {

And, later: 然后:

if (!saslprep) {
    console.warn('Warning: no saslprep library specified. Passwords will not be sanitized');
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM