Search code examples
node.jsreact-fullstack

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);

Output:

Server running on port: ${PORT}

Solution

  • The server is running on PORT but the syntax you used to console.log is called Template literals.

    So it will be `(backtick) instead of '(quote).

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