I'm trying to run the below code using this command: node server.js, but when I run it I get this error message:

Identifier 'app' has already been declared.

Here is my code:

// call all the required packages
const express = require('express')
const bodyParser= require('body-parser')
const multer = require('multer');
app.use(bodyParser.urlencoded({extended: true}))

const app = express()

//CREATE EXPRESS APP
const app = express();

//ROUTES WILL GO HERE
app.get('/', function(req, res) {
    res.json({ message: 'WELCOME' });   
});

app.listen(3000, () => console.log('Server started on port 3000'));

Can someone please tell me why this error is being displayed? I know it's because app is being declared twice, but this code is copied straight from here

Thanks a lot in advance!

0 Answers