I am trying to create a simple request However I am getting the following error
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'C:\Users\wgupta\Backend\temp\index.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
This is the code I have written
const app = require('express')()
const bodyParser = require('body-parser')
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.post('/', (req, res, next) => {
console.log(req.body)
res.json(req.body.adMeta);
})
const port = 3000;
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
node index.js
in a directory which doesn't have anindex.js
in it.