当前位置: 首页 > 知识库问答 >
问题:

升级依赖项时反应“TypeError:路径必须是字符串。接收到的未定义”

岑俊明
2023-03-14

在将依赖项升级到最新版本时,我的mern stack应用程序崩溃,我收到一条typeError消息

TypeError:路径必须是字符串。接收未定义

有人能帮忙吗?提前感谢。以下是错误:

TypeError: Path must be a string. Received undefined
at assertPath (path.js:28:11)
at Object.join (path.js:489:7)
at noopServiceWorkerMiddleware (C:\Projects\react-portfolio\comfort-app\node_modules\react-dev-utils\noopServiceWorkerMiddleware.js:14:26)
at Layer.handle [as handle_request] (C:\Projects\react-portfolio\comfort-app\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\Projects\react-portfolio\comfort-app\node_modules\express\lib\router\index.js:317:13)
at C:\Projects\react-portfolio\comfort-app\node_modules\express\lib\router\index.js:284:7
at Function.process_params (C:\Projects\react-portfolio\comfort-app\node_modules\express\lib\router\index.js:335:12)
at next (C:\Projects\react-portfolio\comfort-app\node_modules\express\lib\router\index.js:275:10)
at launchEditorMiddleware (C:\Projects\react-portfolio\comfort-app\node_modules\react-dev-utils\errorOverlayMiddleware.js:20:7)
at Layer.handle [as handle_request] (C:\Projects\react-portfolio\comfort-app\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\Projects\react-portfolio\comfort-app\node_modules\express\lib\router\index.js:317:13)
at C:\Projects\react-portfolio\comfort-app\node_modules\express\lib\router\index.js:284:7
at Function.process_params (C:\Projects\react-portfolio\comfort-app\node_modules\express\lib\router\index.js:335:12)
at next (C:\Projects\react-portfolio\comfort-app\node_modules\express\lib\router\index.js:275:10)
at handleWebpackInternalMiddleware (C:\Projects\react-portfolio\comfort-app\node_modules\react-dev-utils\evalSourceMapMiddleware.js:42:7)
at Layer.handle [as handle_request] (C:\Projects\react-portfolio\comfort-app\node_modules\express\lib\router\layer.js:95:5)    

package.json文件:


{
  "name": "comfort-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@fortawesome/react-fontawesome": "^0.1.9",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "axios": "^0.19.1",
    "bootstrap": "^4.4.1",
    "cloudinary-core": "^2.8.2",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-redux": "^7.2.0",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.3.0",
    "redux": "^4.0.5",
    "redux-devtools-extension": "^2.13.8",
    "redux-thunk": "^2.3.0"
  },
  "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"
    ]
  }
}

我应该降级到以前版本的纱线吗?我担心如果我这样做,我会得到更多的错误。任何想法...?

共有1个答案

戈睿识
2023-03-14

这是一个在react中修复的错误-script@3.4.0,将package.json中的react scripts更改为“react scripts”:“3.4.0”,然后运行warn install,或者您只需执行以下操作:

yarn add react-scripts@3.4.0
 类似资料: