I've got a web development project based on e-commerce but when I try to run my project on the local server I always getting this type of error. Don't find any solution yet.
For better understanding, I added my server.js and package.json file in the post
Here it is sever.js
import express from 'express';
import data from './data';
const app = express();
app.get("/api/products", (req, res) => {
res.send(data.products);
});
app.listen (5000, () => {console.log("Server started at http://localhost:5000")})
In package.json
{
"name": "web-development",
"version": "1.0.0",
"description": "nothing",
"main": "nothing",
"scripts": {
"start": "nodemon --watch backend --exec babel-node backend/server.js"
},
"repository": {
"type": "git",
"url": ""
},
"author": "",
"license": "ISC",
"bugs": {
"url": ""
},
"homepage": "",
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.11.1",
"@babel/node": "^7.10.5",
"@babel/preset-env": "^7.11.0",
"nodemon": "^2.0.4"
}
}
Update: As far console, I added "type": "module", package.json now I get another error
Cannot GET /
Showing in my browser