我已经在 node 中使用 mass.js 几个月了,从来没有遇到过这个错误。我完全被难住了。这是我正在使用的代码:
require('dotenv').config()
const{CONNECTION_STRING, SERVER_PORT, SESSION_SECRET} = process.env
const massive = require('massive')
const express = require('express')
const app = express()
const session = require('express-session')
app.use(express.json())
app.use(session({
resave: true,
saveUninitialized: false,
secret: SESSION_SECRET,
cookie: {
maxAge: 1000 * 60 * 60 * 2
}
}))
massive({
connectionString: CONNECTION_STRING,
ssl: {
rejectUnauthorized: true
}
})
.then(dbInstance => {
app.set('db', dbInstance)
app.listen(SERVER_PORT, () => console.log(`Server is bumping on ${SERVER_PORT}`))
})
.catch(err => console.log(err))
当我运行 nodemon 时,我收到一个错误:“错误:自签名证书”。我知道它与大量有关,因为当我取出它时,nodemon 连接到服务器。当我将rejectUnauthorized 的值更改为false 时,我收到此错误:“TypeError:client.ref 不是函数”。我尝试在命令行和代码中运行“process.env.NODE_TLS_REJECT_UNAUTHORIZED = “0”,但没有运气。任何形式的帮助将不胜感激。