I'm working on a project with next.js and I'm trying to set up an express server but getting the following error:
This is the server.js:
const express = require('express');
const next = require('next');
const dev = process.env.NODE_ENV !== 'production';
const app = next({dev});
const handle = app.getRequestHandler();
app.prepare()
.then(() => {
const server = express();
server.get('*', (req, res) => {
return handle(req, res);
});
server.listen(3000, (err) => {
if (err) throw err;
console.log('> Ready on http://localhost:3000');
});
})
.catch((ex) => {
console.error(ex.stack);
process.exit(1);
});
and the package.json:
{
"name": "makeyka",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "node server.js",
"build": "next build",
"start": "NODE_ENV=production node server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@zeit/next-sass": "^1.0.1",
"axios": "^0.19.0",
"express": "^4.17.1",
"next": "^9.0.6",
"node-sass": "^4.12.0",
"react": "^16.9.0",
"react-dom": "^16.9.0"
}
}
As I'm new to next and express I can't figure out the problem here