custom-express.js :
require('marko/node-require').install()
require('marko/express')
const express = require('express')
const app = express()
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({
extended: true
}));
const routes = require('../app/routes/routes')
routes(app)
module.exports = app
package.json
{
"name": "casa-codigo",
"version": "1.0.0",
"description": "projeto node da alura",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon server.js --ignore *.marko.js"
},
"author": "Igor Gomes",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"express": "4.16.3",
"marko": "^4.13.4-1",
"mysql": "^2.18.1",
"sqlite3": "^4.1.1"
},
"devDependencies": {
"nodemon": "^1.18.4"
}
}
obs: Na aula pede ser a versão 1.18.3 do body-parse mas mesmo com ela não funciona
erro:
events.js:298
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3030
at Server.setupListenHandle [as _listen2] (net.js:1309:16)
at listenInCluster (net.js:1357:12)
at Server.listen (net.js:1445:7)
at Function.listen (/home/igor/Alura/Node/CasaCodigo/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/home/igor/Alura/Node/CasaCodigo/server.js:3:5)
at Module._compile (internal/modules/cjs/loader.js:1144:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1164:10)
at Module.load (internal/modules/cjs/loader.js:993:32)
at Function.Module._load (internal/modules/cjs/loader.js:892:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1336:8)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '::',
port: 3030
}
[nodemon] app crashed - waiting for file changes before starting...