简体   繁体   中英

"'npm' is not recognized as an internal or external command" on create-react-app

Why is npm not recognized?

I'm trying to learn react and get started using it. I have node installed, and the package create-react-app.

If I type in my command line, npm -v or create-react-app -V , it will return the current versions I have. Which is step one in my problem.

Step two would be checking the environment paths.

I have C:\\Users\\hunte\\AppData\\Roaming\\npm in my paths and I even ran my bash command line as administrator with no such luck.

Step three I assume would be restarting my computer. (Obviously it didn't work)

How I installed and tried to step up react is like this...

npm install -g create-react-app

create-react-app my-app

Then it returns 'npm' is not recognized as an internal or external command.

I'm lost, looking for some help to resolve this as I really eager to learn react.js.

Thank's to all who spend the time reading my question.

Here's my cmd

$ create-react-app test

Creating a new React app in C:\Users\hunte\desktop\test\test.

'npm' is not recognized as an internal or external command,
operable program or batch file.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

'npm' is not recognized as an internal or external command,
operable program or batch file.

Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scripts@0.9.x has failed.

Deleting generated file... package.json
Deleting test/ from C:\Users\hunte\desktop\test
Done.

I've figured it out!

For everyone who runs into a similar problem all I did to get it to work was change CMDs.

I was using the Git Bash CMD as I like it better; however, I guess it doesn't work well with the system paths/environments.

All I did to fix this issue to run my default cmd as administrator and tried again. This time it worked and I was successful in creating the react package.

Using the default Command Prompt worked for me. I was previously working on Hyper.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM