【问题标题】:React-server failling without error反应服务器失败而没有错误
【发布时间】:2017-03-04 00:34:46
【问题描述】:

我从 generator-react-server 创建了一个简单的项目。一切正常。

我刚刚创建了一个新路由一个新页面和一个新组件,并为 home.js 更改了 hello-world.js(页面和组件)。

现在,当运行 npm startreact-server start 时,服务器关闭时不会返回任何特定错误,但会返回以下日志(请注意,它在之前运行时已经记录了相同的消息)。

2016-10-21T15:44:01.071Z - warning: [react-server-cli.src.logProductionWarnings] PRODUCTION WARNING: the following current settings are discouraged in production environments. (If you are developing, carry on!):
2016-10-21T15:44:01.075Z - warning: [react-server-cli.src.logProductionWarnings] -- Minification is disabled. To enable, set minify to true (--minify at the command-line) or set NODE_ENV=production.
2016-10-21T15:44:01.076Z - warning: [react-server-cli.src.logProductionWarnings] -- Long-term caching is disabled. To enable, set longTermCaching to true (--long-term-caching at the command-line) or set NODE_ENV=production to turn on.
2016-10-21T15:44:01.076Z - info: [react-server-cli.src.logProductionWarnings] NODE_ENV is set to undefined

【问题讨论】:

    标签: reactjs react-server


    【解决方案1】:

    问题是 routes.js 中定义的路由仍然指向一个不再存在的页面(page 属性)。路由无法解析。

    routes.js

    {
      "middleware": [],
      "routes": {
      "Homepage": {
        "path": "/",
        "page": "pages/home.js"
      }
    }
    

    【讨论】:

      【解决方案2】:

      您好先生,您必须按照以下步骤运行您的代码

      安装 yeoman

      npm install -g 哟

      安装 react-server 生成器

      npm install -g generator-react-server

      在 CURRENT 目录下新建一个 react-server 项目

      你的反应服务器

      运行新应用

      npm 运行开始

      转到http://localhost:3000

      【讨论】:

        猜你喜欢
        • 2018-01-18
        • 2018-04-06
        • 2018-06-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-07-05
        • 1970-01-01
        相关资源
        最近更新 更多