升级依赖项时反应“TypeError:路径必须是字符串。收到未定义”
Posted
技术标签:
【中文标题】升级依赖项时反应“TypeError:路径必须是字符串。收到未定义”【英文标题】:React "TypeError: Path must be a string. Received undefined" while upgrading dependencies 【发布时间】:2020-08-14 12:45:25 【问题描述】:将依赖项升级到最新版本时,我的 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"
]
我应该降级到以前版本的 yarn 吗?恐怕如果我这样做,我会得到更多的错误。有什么想法吗?
【问题讨论】:
【参考方案1】:这是一个bug that was fixed in react-script@3.4.0
,将你的package.json中的react-scripts
更改为"react-scripts": "3.4.0",
并运行yarn install
或者你可以这样做:
yarn add react-scripts@3.4.0
【讨论】:
谢谢分数!!!你救了我的命!我对使用问答功能很陌生。我怎么给你信任我的朋友! 很高兴我能帮上忙,你可以upvote and accept the answer 我想知道你试过什么 cmd ?yarn install
?
我使用了 yarn add react-scripts@3.4.0
哦。我使用了纱线更新 cmd。它告诉我某些东西已被弃用,所以我输入了它建议的 cmd。以上是关于升级依赖项时反应“TypeError:路径必须是字符串。收到未定义”的主要内容,如果未能解决你的问题,请参考以下文章
当我没有使用该注释或任何与 MVC 相关的依赖项时,Spring 会抱怨 @EnableWebMvc