Reputation: 1349
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\
Upvotes: 51
Views: 129744
Reputation: 6823
The below steps worked for me :
Install create-react-app globally via the following command.
npm install -g create-react-app
then enter create-react-app
command with --template
flag set to typescript
with your app name.
create-react-app <your-app-name> --template typescript
Happy coding...
Upvotes: 0
Reputation: 567
My problem was my Windows Account name. I changed like this
Hüseyin Baduk -> huseyinbaduk
. But you need to be careful this change process corrupt your other applications use user data in C:/Users/%/
Upvotes: 0
Reputation: 131
issue: may be you miss somethings library or dependency solution: npm i react-app-env
Upvotes: 0
Reputation: 1
Try This.
npm uninstall -g create-react-app
or
yarn global remove create-react-app
it will solve issue
Upvotes: 0
Reputation: 3754
documentation says: npm init react-app my-app
reference: https://github.com/facebook/create-react-app
Upvotes: 1
Reputation: 11
I solved my problem by following steps
Upvotes: 1
Reputation: 1
This worked for me, seems the create react app has version issue, adding @latest solves it, installing it in local is by no means useful as the use of npx is to get latest version from remote repository that from local.
npx create-react-app@latest react-webdev-course
Upvotes: 0
Reputation: 11
Adding npx to the command solves the problem and react app is created e.g:
$ npx create-react-app my-react-app
Upvotes: 1
Reputation: 21
I was trying to create an app on my PC with Windows PowerShell. I tried updating and setting up environment variables accordingly. But nothing worked for me until I followed these steps.
and then it started working. Use these commands in the same sequence.
Upvotes: 0
Reputation: 27
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.
Upvotes: 0
Reputation: 133
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
Upvotes: 5
Reputation: 74
I solved the problem by using Node.js command prompt as an administrator
Upvotes: 0
Reputation: 335
I reinstalled node.js and added the path given by npm root -g command to my path variable to get it working.
Upvotes: -2
Reputation: 61
Another one that might work is to use Powershell and type:
npx create-react-app new_app --use-npm
Upvotes: 6
Reputation: 51
For me just create-react-app project-name
worked after adding path C:\Users\user\AppData\Roaming\npm\node_modules
to my environment variables.
Upvotes: 0
Reputation: 93
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
Upvotes: 1
Reputation: 167
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
Upvotes: 10
Reputation: 1592
Do the following from TERMINAL
:
cd myReactApp
npx create-react-app .
This should work!
Upvotes: 1
Reputation: 1
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
Upvotes: 0
Reputation: 359
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]
Upvotes: 18
Reputation: 798
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 :-)
Upvotes: 0
Reputation: 406
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
Upvotes: 8
Reputation: 1
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.
Upvotes: -2
Reputation: 11
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.
Upvotes: 0
Reputation: 270
npx install create-react-app nameOfYourFolder
instead of npm
install create-react-app nameOfYourFolder
(npx comes with npm 5.2+
and higher)cd nameOfYourFolder
npm start
You can find more in React documentation here
Upvotes: 2
Reputation: 153
I also get same problem but I resolve it by following steps
Thanks
Upvotes: 3
Reputation: 19
This is the issue is mainly caused by two reasons:
Add C:\Users\ugur\AppData\Roaming\npm to Windows PATH variable and upgrade npm version to 5.5.1
Upvotes: 1