[ERR_INVALID_ARG_TYPE]: The “path“ argument must be of type string. Received undefined报错
启动react项目报错如下:
[ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at validateString (internal/validators.js:120:11)......
造成这种报错可能有两种原因,解决方案如下:
一. 可能是react-scripts版本太低了,解决如下:
1. 在package.json中,把"react-scripts": "^3.3.0" 替换为
"react-scripts": "^3.4.0"
2. 删除node_modules文件夹
3. 执行cnpm i一下
二. 修改config/webpackDevServer.config.js文件,解决如下:
看看config/webpackDevServer.config.js文件中的是不是有如下代码:
app.use(noopServiceWorkerMiddleware());
修改成
app.use(noopServiceWorkerMiddleware('/'));
做个笔记!