在 cpanel 中的 express.js 服务器上出现“无法获取 /index.html”

问题描述 投票:0回答:0

我在https://expressjs.com/en/starter/hello-world.html提供的app.js中写了以下代码

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => {
  res.send('Hello World!')
})

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})

我将它放在 /nodejsapp 文件夹中,并按照一些教程的建议添加了 .htaccess。

i was expecting to get "Hello World!" but instead got "Cannot GET /index.html" 
https://i.stack.imgur.com/tHQ28.png
[](https://i.stack.imgur.com/tHQ28.png)

I am not providing any route to index.html so why is it saying so

my application manager
https://i.stack.imgur.com/2F0xx.png
[](https://i.stack.imgur.com/2F0xx.png)
node.js express hosting cpanel
© www.soinside.com 2019 - 2024. All rights reserved.