[Fix] TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received undefined

Daniel Kondrashevich
2 min readFeb 1, 2022

Have you run into the error “TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received undefined”? In this story I’ll go over three fixes you can try to get rid of this error.

Photo by Elisa Ventur on Unsplash

This story will cover three possible fixes:

  1. Upgrade react-scripts
  2. Change react-scripts from 3.x.x to 3.4.1
  3. Setting the HOME environment variable

1: Upgrade react-scripts

To begin fix #1, open your project folder in your terminal and run the following command:

npm install react-scripts@latest

2: Change react-scripts from 3.x.x to 3.4.1

To begin fix #2, open your package.json file. Search for “react-scripts” and change the version from “3.x.x” to “3.4.1”. Run npm install or yarn install after saving package.json.

Optional: Delete your node_modules folder before running npm install or yarn install.

3: Set the HOME environment variable

To begin fix #3, we need to set an environment variable in our OS.

To set an environment variable in Windows, open Command Prompt in Administrator mode and run the following command:

setx HOME "%USERPROFILE%"

To set an environment variable in macOS / OS X or Linux, open your terminal and run the following command:

Note: replace /your/path with the home path in your OS.

export HOME=/your/path

After changing the environment variables, run npm install or yarn install

Feel free to leave a response if you run into any issues or something is unclear. Happy Coding and God Bless!

--

--

Daniel Kondrashevich

Code-With Sr. CSA at Microsoft. "By the Grace of God, I am what I am"