【问题标题】:npm start is not working (WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE)npm start 不工作(WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE)
【发布时间】:2022-11-13 11:47:43
【问题描述】:

我尝试通过创建一个新的反应应用程序

npx create-react-app myapp    
cd myapp
npm start

我正在使用反应版本 18.2.0

{
  "name": "myapp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.3.0",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },

然后我出错了,我的应用程序也没有在浏览器中打开。 (我尝试手动打开本地主机但没有运气)

(node:8168) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:8168) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.

【问题讨论】:

  • 你能检查一下你使用的是哪个版本的 create React app 吗?
  • 反应版本 18.2.0

标签: reactjs npm node-modules


【解决方案1】:

尝试更改 webpackDevServer.config.js 中的名称对我有用。

1. 打开 node_modules 文件夹。
2. 搜索 webpackDevServer.config.js。
3.打开js文件并进行编辑。

【讨论】:

  • 还有其他有效的方法来解决这个问题吗?还是我必须每次都这样做?
【解决方案2】:
猜你喜欢
  • 2017-07-15
  • 1970-01-01
  • 2021-02-01
  • 2017-06-21
  • 2021-03-11
  • 2017-09-22
  • 2018-09-25
  • 2021-09-07
  • 2019-06-04
相关资源
最近更新 更多