42
votes

I am trying to set up react app using create-react-app command on windows pc. I already used it on my mac computer, and it works well. But I encounter a problem. Here my steps on command line. Am i missing something?

C:\Windows\system32>cd C:\Users\ugur\Desktop\deneme

C:\Users\ugur\Desktop\deneme>npm init


This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See 'npm help json' for definitive documentation on these fields
and exactly what they do.

Use 'npm install <pkg> --save' afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
name: (deneme)
version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
license: (ISC)
About to write to C:\Users\ugur\Desktop\deneme\package.json:

{
   "name": "deneme",
   "version": "1.0.0",
   "description": "",
   "main": "index.js",
   "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
   },
   "author": "Ugur <[email protected]> (http://www.abc.com.tr)",
   "license": "ISC"
}


Is this ok? (yes)

C:\Users\ugur\Desktop\deneme>npm install -g create-react-app
C:\Users\ugur\AppData\Roaming\npm\create-react-app -> C:\Users\ugur\
AppData\Roaming\npm\node_modules\create-react-app\index.js
C:\Users\ugur\AppData\Roaming\npm
`-- [email protected]
  +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | | `-- [email protected]
  | +-- [email protected]
  | `-- [email protected]
  +-- [email protected]
  | +-- [email protected]
  | | +-- [email protected]
  | | `-- [email protected]
  | `-- [email protected]
  |   `-- [email protected]
  +-- [email protected]
  `-- [email protected]


C:\Users\ugur\Desktop\deneme>create-react-app new_app

'create-react-app' is not recognized as an internal or external command, operable program or batch file.

Also npm configuration path is like

C:\Users\ugur\AppData\Roaming\npm\node_modules\create-react-app\

25

25 Answers

100
votes

Try with this npx create-react-app my-app

52
votes

I solved the problem by adding C:\Users\ugur\AppData\Roaming\npm to windows PATH variable.

16
votes

simply putting 'npx' in front of the command will solve this if you are running older version of node.

try this and it will work fine.

npx create-react-app [yourProjectName]

10
votes

I'm adding this because this pops up on Google and I was having trouble.

I'm on Windows 10 and I searched for 'create-react-app' in C:\ and the path was C:\Users\Admin\AppData\Roaming\npm\node_modules.

I added that to the Environment Variables > Path and the command works now.

8
votes

Use npx create-react-app my-app. This will solve any issue with the system path variable.

React GitHub documentation suggests this as well. Read Here

7
votes

First Check your Node version. if your node version is 8 or greater then 8 then use
'npx create-react-app my-app'

In the above version we need to change only one word that is npx

You don't need to do another things. I hope this will help you

6
votes

Another one that might work is to use Powershell and type:

npx create-react-app new_app --use-npm
3
votes

I also get same problem but I resolve it by following steps

  1. Check your global directory by using command npm root -g
  2. check the folder, will it have .cmd of your installed packages.
  3. If yes, Please copy the path of folder and put in path of user variables.

Thanks

2
votes

I had to add c:\node_modules.bin to my path to run create-react-app

Do a search for create-react-app and use that in your path.

2
votes
  • Run : npx install create-react-app nameOfYourFolder instead of npm install create-react-app nameOfYourFolder (npx comes with npm 5.2+ and higher)
  • Then : cd nameOfYourFolder
  • Then run : npm start

You can find more in React documentation here

2
votes

Do the following from TERMINAL:

  • cd myReactApp
  • npx create-react-app .

This should work!

1
votes

This is a windows variable path problem, i have faced the same problem recently, the following are possible root cause of the problem , installing node via nvm(node version manager) so to solve the issue in this case you after running npm install -g create-react-app got to the location in my case C:\Users\pc\AppData\Roaming\npm in the copy create-react-app to C:\Users\pc\AppData\Roaming\nvm\v12.18.3 and also move the folder in node_module folder called create-react-app to the specific version you are using under nvm , after that you should be able to use create-react-app without and issue. i hope this will help someone

1
votes

User following command

npx create-react-app my-app

1
votes

I faced the same issue despite having

npm install create-react-app --global

Later tried

npm init react-app projectname

This worked for me and it created a React project. Also this worked

npx create-react-app projectname
0
votes

This is the issue is mainly caused by two reasons:

  1. Path variable issue
  2. Npm version issue

Add C:\Users\ugur\AppData\Roaming\npm to Windows PATH variable and upgrade npm version to 5.5.1

0
votes

By installing react globally this error can be solved for those who didn't get even after the environmental variable is set. npm i -g create-react-app . Now the modules will be installed.

0
votes

If above solution not working try this on it will work 100%

0)first of all install package "npm create-create-app -g" or "yarn add create-react-app" then

1)open cmd and type "npm root -g" this command will give you path of node_model directory for global packages

2) copy that path only upto npm directory eg.C:\Users\vchaudhari\AppData\Roaming\npm

3) open environmental variables in windows and pest that command in that save it .

4) close current cmd and open new cmd and use command "create-react-app demoapp"

5) Enjoy :-)

0
votes

Environment node -v: v8.9.3 npm -v:4.6.1 yarn --version (if you use Yarn): npm ls react-scripts (if you haven’t ejected): C:\Users\chacker\my-react-app>npm ls react-scripts [email protected] C:\Users\chacker\my-react-app `-- (empty) Then, specify:

Operating system: windows 7 Browser and version (if relevant): Steps to Reproduce (Write your steps here:)

npm install -g create-react-app log-> C:\Users\chacker\my-react-app>npm install -g create-react-app C:\Users\chacker\AppData\Roaming\npm\create-react-app -> C:\Users\chacker\AppData\R aming\npm\node_modules\create-react-app\index.js C:\Users\chacker\AppData\Roaming\npm `-- [email protected] create-react-app my-app

0
votes

This command requires the Expo-CLI. If you want to save time I recommend to you the Node.js command prompt and it will add the necessary dependencies automatically.

0
votes

For me just create-react-app project-name worked after adding path C:\Users\user\AppData\Roaming\npm\node_modules to my environment variables.

0
votes

I solved the problem by using Node.js command prompt as an administrator

0
votes

Someone who is still having this issue, Go to C:\Users\user\AppData\Roaming\npm- check if .cmd is create-react- app or creact-react-native-app.

Mine was the latter.

Also, make sure you don't have two different version installed.

-1
votes

I solved the problem by uninstalling create-react-app:

npm uninstall create-react-app

then install with the following command:

npm install -g create-react-app
-2
votes

I solved problem by following below steps

1) open Node.js command prompt

2) Then type "npm install create-react-app -g" (g for global access) command to install create-react-app

3) Then type "npm install create-react-native-app -g" (g for global access) command to install create-react-native-app

Follow step #2 for use create-react-app

Follow step #3 only if you want to use create-react-native-app otherwise its optional.

-2
votes

I reinstalled node.js and added the path given by npm root -g command to my path variable to get it working.