I started a new nodejs project on Heroku. The code works on my machine just fine but when I run it on Heroku I get this message:
Failed to lookup view "index.jade" in views directory "/app/server/views"
Knowing that I DO HAVE the "index.jade" file in directory "/app/server/views".
OS :windows 10.
Server.js File
var express = require('express');
var path = require ('path');
var connectionString = "mongodb://localhost:27017/TravelWithMe";
stylus = require ('stylus');
logger = require('morgan');
bodyParser = require('body-parser');
mongoose = require('mongoose');
var app = express();
function compile (str,path)
{
return stylus(str).set('filename',path);
}
app.set('views',path.join(__dirname ,'server/views'));
app.set('view engine', 'jade');
app.use(logger('dev'));
app.use(bodyParser.urlencoded({extended:true}));
app.use(bodyParser.json());
app.use(stylus.middleware(
{
src: path.join(__dirname ,'public'),
compile: compile
}
));
app.use(express.static(path.join(__dirname ,'public')));
mongoose.connect(connectionString);
var db = mongoose.connection;
db.on('error',console.error.bind(console,'connection error ...'));
db.once('open',function callback() {
console.log('TWM Db opened')
});
app.get('/partials/:partialPath', function(req, res) {
res.render('partials/' + req.params.partialPath);
});
app.get('*',function (req,resp){
resp.render('index.jade',{MongoMessage : MongoMessage});
});
var port = process.env.PORT || 3030;
app.listen(port);
via Bakri Bitar
No comments:
Post a Comment