首页 > 解决方案 > 本地主机不会打开(Node.js 服务器)

问题描述

我在 node.js 中为我的项目创建了一个服务器,但 localhost 无法打开。

服务器显然可以工作,但是当我输入 http://localhost:8080 / 页面正在加载并且无法打开。

我正在为服务器使用快递。

我一直试图解决它几个小时,但我找不到任何东西来解决它。

项目文件夹是 \wsl$\Ubuntu\home\fplp\projects\Node-js-projects。

我在适用于 Linux 的 Windows 子系统中有 Ubuntu 20.04 LTS

接下来我将展示服务器的代码和终端页面的照片。

//这是server.js文件\

    const express = require('express');
const app = express();

app.set("view engine", "ejs");

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

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

app.listen(8080);
console.log("Server is Online");

//终端照片(wsl)。

超级终端照片(wsl)

标签: node.jsexpress

解决方案


推荐阅读