连接到 Mongoose 时,我指定了自定义端口:5000,但输出:Server 运行 on port: ${PORT}

While connecting to Mongoose, i specified custom port: 5000, but output: Server running on port: ${PORT}

const PORT = process.env.PORT || 5000;

mongoose.connect(CONNECTION_URL, { useNewUrlParser: true, useUnifiedTopology:true })
.then(() => app.listen(PORT, () => console.log('Server running on port: ${PORT}'))) 
.catch((error) => console.log(error.message));

mongoose.set('useFindAndModify', false);

输出:

Server running on port: ${PORT}

服务器是 PORT 上的 运行,但您用于 console.log 的语法称为 Template literals

所以它将是 `(反引号)而不是 '(引号)。

.then(() => app.listen(PORT, () => console.log(`Server running on port: ${PORT}`)))