Answer the question
In order to leave comments, you need to log in
Error: Cannot find module 'jade'?
Good afternoon.
The error Error: Cannot find module 'jade' is displayed when entering the site, i.e. when the render command fires.
Googling, I found a solution - install the jade package globally and install (npm i -g).
Tried everything that came to mind.
app.js
var express = require('express'),
http = require('http'),
path = require('path');
var config = require('./config/'),
log = require('./libs/log')(module);
var app = express();
app.set('views', __dirname + './template');
app.set('view engine', 'jade');
app.use(express.favicon());
if(app.get('env') == 'development') {
app.use(express.logger('dev'));
} else {
app.use(express.logger('default'));
}
app.use(express.bodyParser()); // req.body.....
app.use(express.cookieParser()); //req.cookies
app.use(app.router);
app.get('/', function(req, res, next) {
res.render("index", {})
});
app.use(express.static(path.join(__dirname, 'public')));
////////////////////////////////////////////////////////
http.createServer(app).listen(config.get('port'), function() {
log.info('Express server listening on port ' + config.get('port'));
});
// Middleware
app.use(function(req, res) {
res.send(404, 'Page not found');
});
app.use(function(err, req, res, next) {
if(app.get('env') == 'development') {
var errorHandler = express.errorHandler();
errorHandler(err, req, res, next);
}
})
{
"name": "asd",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "set NODE_ENV=development&& nodemon app.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.14.0",
"jade": "^1.11.0"
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question