I am new to node.js i am following blog and practicing how to create a new blog
https://vegibit.com/node-js-blog-tutorial/
Till this steps everything works fine "Edge Template Engine With Express" , once i added the below lines
app.use(expressEdge);
app.set('views', __dirname + '/views');
I am getting the below error.
C:\Automation\NodeJS_Projects-master\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:\Automation\NodeJS_Projects-master\nodejs-blog-tutorial\node_modules\express\lib\application.js:210:11) at Object. (C:\Automation\NodeJS_Projects-master\nodejs-blog-tutorial\index.js:8:5) at Module._compile (internal/modules/cjs/loader.js:1138:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10) at Module.load (internal/modules/cjs/loader.js:986:32) at Function.Module._load (internal/modules/cjs/loader.js:879:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47
Full code tried to far
const express = require('express');
var slash = require("slash");
const expressEdge = require('express-edge');
const app = new express();
var dirname = __dirname;
if (process.platform === 'win32') dirname = slash(dirname);
app.use(express.static('public'));
app.use(expressEdge);
app.set('views', dirname + '/views');
mongoose.connect('mongodb://localhost:27017/node-blog', { useNewUrlParser: true })
.then(() => 'You are now connected to Mongo!')
.catch(err => console.error('Something went wrong', err))
app.get('/posts/new', (req, res) => {
res.render('create')
});
app.get('/', (req, res) => {
res.render('index');
});
app.get('/about', (req, res) => {
global.__base = dirname + '/pages/about.html';
console.log(global.__base)
res.sendFile(global.__base);
});
app.get('/contact', (req, res) => {
global.__base = dirname + '/pages/contact.html';
res.sendFile(global.__base);
});
app.get('/post', (req, res) => {
global.__base = dirname + '/pages/post.html';
res.sendFile(global.__base);
});
app.listen(4000, () => {
console.log('App listening on port 4000')
});