U
U
Umid2017-01-25 13:57:33
Node.js
Umid, 2017-01-25 13:57:33

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);
  }
})

package.json
{
  "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"
  }
}

Jade installed both locally and globally.
Axis win7.
9108a703e56743f588cae84b4d09d35b.png
And one more thing, I tried to install express locally in a folder.
The server doesn't even start:
af845b996fdf4689b8f24018b2a70762.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question