Saturday, 15 April 2017

Error: Cannot find module 'html' with Node.JS and Express

I've been looking at responses on here for this question, but nothing has helped me. Some solutions have given me even more errors, too.

What I am trying to do is route to different pages with Node.JS. Having learnt a little bit on the MEAN stack, I decided to use Node, Express, and Angular (haven't gotten there yet). If I try to to to any place that isn't the '/' route, I get an error saying 'Cannot find module 'html'. Below is the code in question:

//dependencies
var express = require('express');
var path = require('path');
var engines = require('consolidate')

//variables
var RUN_PORT = 8080;
var VIDEO_IN_PORT = 45679;
var CONTROL_OUT = 45678;
var app = express();

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

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

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

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

//showing that the program is running on the RUN_PORT
app.listen(RUN_PORT, function(){
    console.log("Running on port " + RUN_PORT);
});

What am I not seeing here? Everything seems to look fine. All I have installed in my package.json is Express. I am able to get to the index page just fine, but anything other than that causes that error.



via TheLegendOfCode

No comments:

Post a Comment