‘create-react-app’ is not recognized as an internal or external command OR The term ‘create-react-app’ is not recognized
If you’re using Windows to develop react apps, you might come across this error in Command Prompt (cmd.exe):
‘create-react-app’ is not recognized as an internal or external command
Or in PowerShell (powershell.exe):
create-react-app: The term ‘create-react-app’ is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
This, of course, means create-react-app
cannot be found. This can be caused by a few things:
- create-react-app is not installed
- The npm folder does not exist environmental PATH variable
- Something is wrong with npm
Let’s go in order to ensure everything is set up as expected.
Do npm and npx work?
In Command Prompt or PowerShell, type:
npm
and press enternpx
and press enter
Do both commands work? If one or both commands do not work, I recommend installing nvm
(Node version manager), which makes installing and switching between NodeJS versions easy. See this site for instructions.
Is create-react-app actually installed?
Make sure create-react-app
is installed.
In Command Prompt or PowerShell, type:
npm install --global create-react-app
Once it’s installed, type create-react-app
and press enter.
If it’s still broken, there’s probably only one reason it’s not working: missing folder in the PATH variable
Fix PATH environment variable
If everything is correct so far, then the problem is most likely a problem with the PATH variable. Not a hard fix, don’t worry.
The PATH variable is an environmental variable that contains a list of folders that Windows uses to access a file from any directory. So if the PATH variable contains C:\Windows\System32
and you’re in another directory such as C:\Users
, typing calc.exe
will launch Calculator as if you were in the C:\Windows\System32
directory (since calc.exe
is actually located in C:\Windows\System32).
Applying this to NodeJS, the PATH variable must contain the folder where the NodeJS the .cmd
files reside that call the scripts such as create-react-app
:
Open PowerShell as Administrator (not Command Prompt) and type:
explorer (npm — global root)\..
and press enter
That should take you to a folder that contains:
- node.exe
- npm.cmd
- create-react-app.cmd
and a few other files.
If you don’t see these files, you need to reinstall NodeJS.
If you do see these files, good! Now we just need to add this folder to the PATH variable.
- Press Win+R and type
sysdm.cpl
and press enter - Click the
Advanced
tab and clickEnvironment Variables
at the bottom - In the bottom section where it says
System variables
, find thePath
variable and double-click it - Click
New
and then type the name of the folder that opened in the previous step - Note that my path is
C:\Program Files\nodejs
but yours may be different (such as in AppData), that’s okay!
- Make sure to click
Move Up
until it’s at the very top of the list - Click OK when done
- Restart your computer (required in order to reload the system environment variables)
That should take care of it! Have fun coding! 😊
Consider becoming a Medium member if you appreciate reading stories like this and want to help me as a writer. It costs $5 per month and gives you unlimited access to Medium content. I’ll get a little commission if you sign up via my link.