我正在用React做一个项目,遇到了一个让我难住的问题。

当我运行yarn start时,我得到这个错误:

TypeError [ERR_INVALID_ARG_TYPE]: "path"参数必须是类型 字符串。接收类型未定义

我不知道为什么会这样。


当前回答

从powershell切换到bash为我解决了这个问题。

其他回答

我也遇到过这个问题,并通过从“react-scripts”:“3.x”升级react-scripts包来解决它。X "到"react-scripts": "^3.4.1"(或最新可用版本)。

删除“node_modules\”文件夹 删除package-lock。json文件 重写包。Json文件从"react-scripts": "3.x。X " to "react-scripts": "^3.4.1" 重新安装节点包 现在,启动项目npm start

而且很管用!!

在同一个目录包里。json, package-lock。Json和yarn.lock。它帮助我删除纱线。锁目录。尽管我不想使用纱线,但它还是以某种方式添加到我的项目中

去你的package.json 修改“react-scripts”:“3.x。X”到“react-scripts”:依赖项中的“^3.4.0” 重新安装react-scripts: npm I react-scripts 启动你的项目:npm Start

其他的解决方法对我都不起作用。

但是,将这个添加到我的包中。Json为我解决了这个问题:

"resolutions": {
  "react-dev-utils": "10.0.0"
},

只需将反应脚本更新到最新版本。

yarn add react-scripts@latest

或者如果使用NPM

npm install react-scripts@latest