React App:为什么在尝试运行npm start脚本时出现错误? [英] React App: Why I get an error when I try to run npm start script?

查看:240
本文介绍了React App:为什么在尝试运行npm start脚本时出现错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了所有必需的软件包,并尝试运行 npm start 脚本,这给了我以下错误:

I installed all required packages and trying to run npm start script which gives me the error below:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:118:11)
    at Object.join (path.js:375:7)
    at noopServiceWorkerMiddleware (C:\Alex\Practise\React website\front-end\node_modules\react-dev-utils\noopServiceWorkerMiddleware.js:14:26)
    at Layer.handle [as handle_request] (C:\Alex\Practise\React website\front-end\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (C:\Alex\Practise\React website\front-end\node_modules\express\lib\router\index.js:317:13)
    at C:\Alex\Practise\React website\front-end\node_modules\express\lib\router\index.js:284:7
    at Function.process_params (C:\Alex\Practise\React website\front-end\node_modules\express\lib\router\index.js:335:12)
    at next (C:\Alex\Practise\React website\front-end\node_modules\express\lib\router\index.js:275:10)
    at launchEditorMiddleware (C:\Alex\Practise\React website\front-end\node_modules\react-dev-utils\errorOverlayMiddleware.js:20:7)
    at Layer.handle [as handle_request] (C:\Alex\Practise\React website\front-end\node_modules\express\lib\router\layer.js:95:5)

这是我的package.json的副本:

Here's copy of my package.json:

{
  "name": "front-end",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "node-sass": "^4.13.1",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-scripts": "3.3.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

我试图删除并重新安装整个项目,并没有运气重新安装节点和软件包。
非常感谢您的帮助!

I tried to delete and reinstall the whole project, reinstall node and packages with no luck. Any help is very appreciated!

推荐答案

升级您的反应脚本 3.4.0 。我刚刚安装了从您的 package.json 提供的模块,并将 react-scripts 升级到了最新版本,一切正常好的。

Upgrade your react-scripts to 3.4.0. I've just installed modules provided from your package.json and upgraded react-scripts to the newest version and everything works fine.

有关 github问题

这篇关于React App:为什么在尝试运行npm start脚本时出现错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆