create-react-app is working only with cmd but not with bash. With bash : 'npx' not recognized as an internal or external command

Viewed 239

I have node installed in my laptop, npm as well as nvm.

enter image description here

I can check node version, npm and nvm. But when I try to run the command: npx create-react-app file-name, it says create-react-app is not recognized as an internal or external command. Even I tried using npm install -g create-react-app and then create-react-app it gives the same type of error. I tried cleaning cache as well.

I have my project files installed in D drive whereas node is in C drive.

Any solutions in this case??? Please help me.

2 Answers

Try by adding path variable, here are steps:

  1. Use the global Search Charm to search "Environment Variables".
  2. Click "Edit environment variables for your account"
  3. Click "Environment Variables" in the dialog.
  4. In the "System Variables" box, search for Path and edit it to include C:\Program Files\nodejs (or path of node installaton). Make sure it is separated from any other paths by a ;
  5. Click on apply and save the settings.

enter image description here

enter image description here

It is mainly a npm version issue, you may be using the older version of npm, if it is so, then try with these commands -

npm install -g create-react-app

and after that

create-react-app project-name

Else, you may upgrade the npm version to use your npx command

Hope this may be helpful to you.

Related