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