首页 > 解决方案 > 错误:不支持选项 gssapiservicename

问题描述

猫鼬(6.0.12)抛出错误Error: option gssapiservicename is not supported

这里是设置 mongodb 连接的代码:

const connectDB = async () => {
try {
    const conn = await mongoose.connect(process.env.MONGO_URI, {
        useUnifiedTopology: true,
        useNewUrlParser: true,
    })

    console.log(`MongoDB Connected: ${conn.connection.host}`.cyan.underline)
} catch (error) {
    console.error(`Error: ${error.message}`.red.underline.bold)
    process.exit(1)
}

}

标签: node.jsmongodbmongoosemern

解决方案


只需删除连接字符串中的参数,较新版本的客户端不再支持此功能


推荐阅读