Sometimes, we may run into the “TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received type undefined” error when starting a React app.
In this article, we’ll look at how to fix the “TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received type undefined” error when starting a React app.
Fix the “TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received type undefined” Error When Starting a React App
To fix the “TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received type undefined” error when starting a React app, we should upgrade the react-scripts
package to the latest version.
To do this, we:
- 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 the
node_modules
folder in the project. - Run
npm install
oryarn install
This error may be caused by running npm audit fix
, so avoid running this command to avoid this error.
Conclusion
To fix the “TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received type undefined” error when starting a React app, we should upgrade the react-scripts
package to the latest version.