Javascript 通过Express提供服务时Index.html不呈现组件

Javascript 通过Express提供服务时Index.html不呈现组件,javascript,reactjs,express,Javascript,Reactjs,Express,我已经完成了本教程的学习 我已将我的App.js更改为以下内容: import React, { Component } from "react"; import "./App.css"; class App extends Component { render() { return ( <div> <p>lmfao</p> </div> ); } } export default

我已经完成了本教程的学习

我已将我的App.js更改为以下内容:

import React, { Component } from "react";
import "./App.css";

class App extends Component {
  render() {
    return (
      <div>
        <p>lmfao</p>
      </div>
    );
  }
}

export default App;
以下是package.json中的依赖项:

"devDependencies": {
    "eslint": "^6.5.1",
    "eslint-config-standard": "^14.1.0",
    "eslint-plugin-flowtype": "^4.3.0",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-node": "^10.0.0",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-react": "^7.16.0",
    "eslint-plugin-react-hooks": "^2.1.2",
    "eslint-plugin-standard": "^4.0.1"
  },
  "dependencies": {
    "concurrently": "^5.0.0",
    "express": "^4.17.1",
    "react-router-dom": "^5.1.2"
  }
编辑:根据要求,这里是该项目的github链接:
您必须对ExpressTest文件夹和客户端子文件夹执行npm安装。最可能的原因是无法下载脚本包


在浏览器中右键单击空白页面并选择“查看页面源”或类似菜单。您将看到.html文件的内容,包括指向

/some path/some name.js
文件的
标记。无法下载所有或部分文件。要确认这一点,只需将浏览器指向
localhost:5000/some path/some name.js
,手动下载包即可。如果无法下载脚本包,请向Express添加路由。

我要做的第一件事是在devtools()中为每个页面打开网络选项卡,然后刷新它们。确定是否提供相同的内容。然后你会有一个更好的想法从那里去。你能在github上推送代码并共享链接吗?这将有助于调试。完成后,请看一看。似乎我必须在git中添加客户端文件夹作为子模块。现在完成了。让我知道,如果事情正在运行…既然Express服务器正在从构建文件夹运行,您在运行这个更改之后运行<代码> NPM运行Bug < /代码>吗?在我的索引文件HTMLL中没有任何脚本标记,这就是解释空白页的问题。您提到的freecodecamp使用Create React应用程序(CRA)。CRA创建
index.html
,文件底部带有
。这些
.chunk.js
文件是React脚本包。您在页面上看到的是从捆绑包执行代码的结果。No bundles=空白页。如果CRA自动使用这些bundle创建index.html,那么为什么它不在my index.html中?那我怎么去那里呢?很有趣。。。您让我找到了正确的答案,我必须转到客户机文件夹,然后运行
npm run build
,然后我只需再次在ExpressTest文件夹中运行服务器(npm run dev),它在localhost:5000上运行,我很高兴它有帮助:)
"devDependencies": {
    "eslint": "^6.5.1",
    "eslint-config-standard": "^14.1.0",
    "eslint-plugin-flowtype": "^4.3.0",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-node": "^10.0.0",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-react": "^7.16.0",
    "eslint-plugin-react-hooks": "^2.1.2",
    "eslint-plugin-standard": "^4.0.1"
  },
  "dependencies": {
    "concurrently": "^5.0.0",
    "express": "^4.17.1",
    "react-router-dom": "^5.1.2"
  }