0

I have created one nodejs application using express to serve my portfolio and my projects. My portfolio is working fine when root is accessed "/" but when i serve my projects like "/FootballScores" and "/FacebookGrabber", one is working half(means all angular files loaded successfully but still it displays nothing) and the other project is not loaded and it shows error :

"Error: Cannot find module 'html'"

Also I have installed all the npm packages. Here is the app.js code:

var express = require("express"),
app = express(),
bodyParser = require("body-parser"),
nodemailer = require("nodemailer"),
xoauth2 = require("xoauth2"),
path = require("path");

app.use(express.static(path.join(__dirname, "public")));
app.use(bodyParser.urlencoded({extended: true}));

app.get("/", function(req, res){
res.render("index.html");
});

app.get("/FacebookGrabber", function(req, res){
res.render("FacebookGrabber/index.html");
});

app.get("/FootballScores", function(req, res){
res.render("FootballScores/index.html");
});

app.listen(3000, process.env.IP, function(){
console.log("Portfolio Server Started!");
});

I think the problem is because of incorrect public path... What can i do so my projects /FootballScores and /FacebookGrabber also gets loaded correctly?

Farhan
  • 751
  • 1
  • 9
  • 17
  • Portfolio is served correctly on root "/", FootballScores is working half same as before, and on "/FacebookGrabber" this text appears : "FacebookGrabber/index.html" instead of "Error: Cannot find module 'html'" – Farhan Jan 12 '18 at 15:31
  • Have you taken a look at: https://stackoverflow.com/questions/16111386/error-cannot-find-module-html It seems there is an issue trying to use both `express/static` and `render` at the same time without an engine. – EvSunWoodard Jan 12 '18 at 15:48
  • Sorry bro, it was my mistake when i copied FacebookGrabber Folder it was empty, there was no index.html file. Thank you for your help. – Farhan Jan 12 '18 at 16:05
  • Common mistake, no worries – EvSunWoodard Jan 12 '18 at 16:07

2 Answers2

0

Sorry guys, it was my mistake when i copied FacebookGrabber Folder it was empty, there was no index.html file. Thank you for your help.

Farhan
  • 751
  • 1
  • 9
  • 17
0

Have you tried setting your view engine to html before your res.render calls?

// View engine
app.set('view engine', 'html');
Stan
  • 476
  • 1
  • 5
  • 15