TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined raised when starting react app
Solution 1:
To fix this issue simply upgrade react-scripts package (check latest version with npm info react-scripts version
):
- 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
Some people reported that this issue was caused by running npm audit fix
(avoid it!).
Solution 2:
If you have ejected, this is the proper way to fix this issue:
find this file config/webpackDevServer.config.js
and then inside this file find the following line:
app.use(noopServiceWorkerMiddleware());
You should change it to:
app.use(noopServiceWorkerMiddleware('/'));
For me(and probably most of you) the service worker is served at the root of the project. In case it's different for you, you can pass your base path instead.