小编The*_*ode的帖子

错误:无法使用 Node.JS 和 Express 找到模块“html”

我一直在查看这里对这个问题的答复,但没有任何帮助我。有些解决方案也给我带来了更多错误。

我想做的是使用 Node.JS 路由到不同的页面。在学习了一些 MEAN 堆栈后,我决定使用 Node、Express 和 Angular(尚未实现)。如果我尝试访问“/”路线以外的任何地方,我会收到一条错误消息“找不到模块‘html’”。下面是有问题的代码:

//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);
}); …
Run Code Online (Sandbox Code Playgroud)

javascript node.js express mean-stack meanjs

-1
推荐指数
1
解决办法
5252
查看次数

标签 统计

express ×1

javascript ×1

mean-stack ×1

meanjs ×1

node.js ×1