I already installed Express, Nodeman, Express-Edge. I using Windows 10. Someone who had a similar problem with me was told that he needed to install the library he had specified. Like I said I already installed it.
in index.js
codes;
const path = require('path');
const expressEdge = require('express-edge');
const express = require('express');
const app = new express();
app.use(express.static('public'));
app.use(expressEdge);
app.set('views', __dirname + '/views');
app.get('/', (req, res) => {
res.render('index');
});
app.get('/about', (req, res) => {
res.sendFile(path.resolve(__dirname, 'pages/about.html'));
});
app.get('/contact', (req, res) => {
res.sendFile(path.resolve(__dirname, 'pages/contact.html'));
});
app.get('/post', (req, res) => {
res.sendFile(path.resolve(__dirname, 'pages/post.html'));
});
app.listen(4000, () => {
console.log('App listening on port 4000')
});
command shell saying:
C:\Users\Maximus\WebstormProjects\untitled4\nodejs-blog-tutorial\node_modules\express\lib\application.js:210
throw new TypeError('app.use() requires a middleware function')
^
TypeError: app.use() requires a middleware function
at Function.use (C:\Users\Maximus\WebstormProjects\untitled4\nodejs-blog-tutorial\node_modules\express\lib\application.js:210:11)
at Object.<anonymous> (C:\Users\Maximus\WebstormProjects\untitled4\nodejs-blog-tutorial\index.js:8:5)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
[nodemon] app crashed - waiting for file changes before starting...
package.json
{
"name": "nodejs-blog-tutorial",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"keywords": [
"blog"
],
"description": "",
"dependencies": {
"express": "^4.17.1",
"express-edge": "^2.0.2",
"nodemon": "^2.0.4",
"startbootstrap-clean-blog": "^5.0.9"
}
}