问题描述
我正在用 React 做一个项目,但遇到了一个让我难住的问题.
I'm working on a project in React and ran into a problem that has me stumped.
每当我运行 yarn start
时,我都会收到此错误:
Whenever I run yarn start
I get this error:
TypeError [ERR_INVALID_ARG_TYPE]: "path" 参数必须是类型细绳.接收类型未定义
我不知道为什么会发生这种情况,如果有人遇到过这种情况,我将不胜感激.
I have no idea why this is happening, if anyone has experienced this I would be grateful.
推荐答案
要解决此问题,只需升级 react-scripts 包(使用 npm info react-scripts 版本检查最新版本代码>):
To fix this issue simply upgrade react-scripts package (check latest version with npm info react-scripts version
):
- 将 package.json
"react-scripts": "^3.xx"
替换为"react-scripts": "^3.4.1"
(或最新的可用版本) - (某些可选)删除您的 node_modules 文件夹
- 运行
npm install
或yarn install
- Replace in your package.json
"react-scripts": "^3.x.x"
with"react-scripts": "^3.4.1"
(or the latest available version) - (optional for some) Delete your node_modules folder
- Run
npm install
oryarn install
有些人报告说这个问题是由运行 npm audit fix
引起的(避免它!).
Some people reported that this issue was caused by running npm audit fix
(avoid it!).
这篇关于TypeError [ERR_INVALID_ARG_TYPE]: “路径"参数必须是字符串类型.启动反应应用程序时引发的接收类型未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!