Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot find module '[object Object]'

var express = require('express');
app = express(),
jade = require('jade'),
path = require('path'),
server = require('http').createServer(app),
io = require('socket.io').listen(server),
users = [];

//view engine
app.set('views', __dirname + '/views');
app.set('view engine', jade);
app.engine('jade', require('jade').__express);

//static path
app.use(express.static(path.join(__dirname,'public')));

//index route
app.get('/',function(req,res){
    res.render('index');
});

server.listen('3000');
console.log('server started..');

I followed a video tutorial, I did the same thing but I got an error of cannot find module of [object Object]. The guy who did the video didn't include require('jade'), it worked for him, but it doesn't work for me. I says jade is not defined if I did not require jade.

like image 919
Nichole A. Miler Avatar asked Nov 24 '25 16:11

Nichole A. Miler


2 Answers

Not relevant to this case, but might assist someone.

I had this problem, and found that a mistake in

app.set('view engine', ejs); 

caused it.

it should have been:

app.set('view engine', 'ejs');
like image 116
Gilad F Avatar answered Nov 27 '25 05:11

Gilad F


Change

var express = require('express'); 

into

var express = require('express'),

Right now express is the only variable that is defined.

like image 32
piscator Avatar answered Nov 27 '25 05:11

piscator



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!