TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined raised when starting react app
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!).
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.
I've also faced this problem and figure out it by upgrading the react-scripts
package from "react-scripts": "3.x.x"
to "react-scripts": "^3.4.1"
(or the latest available version).
- Delete
node_modules\
folder - Delete
package-lock.json
file - Rewrite the
package.json
file from"react-scripts": "3.x.x"
to"react-scripts": "^3.4.1"
- Install node packages again
npm i
- Now, start the project
npm start
And it works!!