[nodemon] 2.0.22
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node backend/server server.js`
**Server started on PORT: undefined in DEVELOPMENT node.**
I tried doing following solution for the above issue but didn't worked:
const app = require('./app');
const dotenv = require('dotenv');
//Setting up config file
dotenv.config({ path: 'backend/config/config.env' })
app.listen(process.env.PORT, () => {
console.log(`Server started on PORT: ${process.env.PORT} in ${process.env.NODE_ENV} node.`)
})
Try changing your dotenv implementation to the following:
const dotenv = require('dotenv');
dotenv.config();
.env file should be located on the same folder as main file where you implement the above code.