在节点server.js中找不到模块

时间:2018-12-28 16:00:06

标签: html

我是Node server.js的新手,所以在我的server.js中,我看到一个错误

 Error: Cannot find module './routes/routegameconsoletype'
   at Function.Module._resolveFilename (module.js:548:15)
   at Function.Module._load (module.js:475:25)
   at Module.require (module.js:597:17)
   at require (internal/module.js:11:18)
   at Object.<anonymous> (C:\Users\joyyy\Documents\website\server.js:6:30)
   at Module._compile (module.js:653:30)
   at Object.Module._extensions..js (module.js:664:10)
   at Module.load (module.js:566:32)
   at tryModuleLoad (module.js:506:12)
   at Function.Module._load (module.js:498:3)

但是,在我的代码中,我包含了./routes/routegameconsoletype。我已在

下添加了我的代码
"use strict";

const express = require("express");
const bodyParser = require("body-parser");

const routegameconsoletype = require('./routes/routegameconsoletype');
const routegameinformation = require('./routes/routegameinformation');
const routegamereview = require('./routes/routegamereview');
const routenews = require('./routes/routenews');
const routeuser = require('./routes/routesuser');
const routevideos = require('./routes/routevideos');

var app = express();
var host = "127.0.0.1";
var port = 8080;
var startPage = "index.html";

app.use(express.static("./public"));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

routegameconsoletype.routegameconsoletype(app);
routegameinformation.routegameinformation(app);
routegamereview.routegamereview(app);
routenews.routenews(app);
routeuser.routeuser(app);
routevideos.routevideos(app);

function gotoIndex(req, res) {
  console.log(req.params);
  res.sendFile(__dirname + "/" + startPage);
 }

app.get("/" + startPage, gotoIndex);

app.route("/");

var server = app.listen(port, host, function() {
  var host = server.address().address;
  var port = server.address().port;

  console.log("Example app listening at http://%s:%s", host, port);
});

非常感谢您!

0 个答案:

没有答案