【问题标题】:NPM build works, NPM start does not (create-react-app)NPM 构建有效,NPM 启动无效(create-react-app)
【发布时间】:2019-03-26 23:10:30
【问题描述】:

我正在使用 create-react-app。当我第一次运行“npm start”时,一切正常。但是,当我取消该过程时,localhost 开始返回 404。

这是我的终端:

Compiled with warnings.

./src/components/NameSelection.jsx
  Line 21:  Expected '===' and instead saw '=='  eqeqeq

./src/components/RelationshipSelection.jsx
  Line 25:  Expected '===' and instead saw '=='           eqeqeq
  Line 99:   'options' is assigned a value but never used  no-unused-vars

./src/components/PreferenceSelection.jsx
  Line 5:  'url' is defined but never used  no-unused-vars

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

^C
Daniels-MacBook-Pro:test dcaine$ yarn start
yarn run v1.9.2
$ serve -s build

   ┌──────────────────────────────────────────────────┐
   │                                                  │
   │   Serving!                                       │
   │                                                  │
   │   - Local:            http://localhost:5000      │
   │   - On Your Network:  http://192.168.1.73:5000   │
   │                                                  │
   │   Copied local address to clipboard!             │
   │                                                  │
   └──────────────────────────────────────────────────┘

我不确定这是否相关,但是:当我最初运行 yarn start 时,它位于端口 3000,取消后它变为 5000。

当我运行 npm build 后跟 npm start 时,应用程序将启动并构建我所做的任何更改,但任何后续更改都不会反映在应用程序中(直到我重复此过程)。

什么可能导致这种情况发生?

【问题讨论】:

    标签: npm http-status-code-404 create-react-app yarnpkg


    【解决方案1】:

    我认为当你混合使用 npm 和 yarn 时可能会出现这个问题,也许吧?我做了什么来解决这个问题:

    1. 删除节点模块
    2. 使用yarn add重新添加模块
    3. yarn start

    现在可以正常使用

    【讨论】:

      猜你喜欢
      • 2017-02-09
      • 1970-01-01
      • 2020-09-23
      • 2020-05-11
      • 2021-04-28
      • 2017-05-04
      • 2017-02-18
      • 1970-01-01
      • 2021-05-18
      相关资源
      最近更新 更多