简体   繁体   中英

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

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 <ugur@abc.com.tr> (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
`-- create-react-app@0.2.0
  +-- chalk@1.1.3
  | +-- ansi-styles@2.2.1
  | +-- escape-string-regexp@1.0.5
  | +-- has-ansi@2.0.0
  | | `-- ansi-regex@2.0.0
  | +-- strip-ansi@3.0.1
  | `-- supports-color@2.0.0
  +-- cross-spawn@4.0.0
  | +-- lru-cache@4.0.1
  | | +-- pseudomap@1.0.2
  | | `-- yallist@2.0.0
  | `-- which@1.2.10
  |   `-- isexe@1.1.2
  +-- minimist@1.2.0
  `-- semver@5.3.0


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\

试试这个npx create-react-app my-app

我通过将C:\Users\ugur\AppData\Roaming\npm添加到 Windows PATH 变量来解决了这个问题。

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]

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.

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

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

另一种可能有效的方法是使用 Powershell 并键入:

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

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

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.

  • 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

Do the following from TERMINAL :

  • cd myReactApp
  • npx create-react-app .

This should work!

User following command

npx create-react-app my-app

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

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

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

将 npx 添加到命令可以解决问题并创建反应应用程序,例如:

$ npx create-react-app my-react-app

I solved my problem by following steps

  1. npm install -g create-react-app To install react app globally
  2. create-react-app version To check if it is installed and if its installed then what's the version.
  3. create-react-app [name]
  4. cd [name]
  5. npm start

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.

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 :-)

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 my-react-app@1.0.0 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 `-- create-react-app@1.4.3 create-react-app my-app

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.

对我来说,在将路径C:\Users\user\AppData\Roaming\npm\node_modules到我的环境变量后, create-react-app project-name就起作用了。

我以管理员身份使用Node.js 命令提示符解决了这个问题

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.

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.

  1. npm install create-react-app
  2. npx create-react-app

and then it started working. Use these commands in the same sequence.

这对我有用,似乎 create react 应用程序有版本问题,添加 @latest 解决了它,在本地安装它绝不是有用的,因为使用 npx 是从本地获取远程存储库的最新版本。

npx create-react-app@latest react-webdev-course

documentation says: npm init react-app my-app

reference: https://github.com/facebook/create-react-app

Try This.

npm uninstall -g create-react-app

or

yarn global remove create-react-app

it will solve issue

The reason I ran into this issue was likely different, but I'm listing it as an answer in case someone else finds this question and it helps them.

I just solved this issue by:

  1. Removing unnecessary globals

    • npm list -g --depth=0
    • npm uninstall -g <args>
  2. Deleting package-lock.json

  3. rm -rf node_modules
  4. npm install

What I think led me to receiving this issue:

I was developing on a playground branch and ran a few commands improperly, such as npm install --prefix client && npm run test --prefix client , from the wrong directory.

I probably created some issues with my package-lock.json and then when I re-installed, had some issues with a babel-eslint global.

Dan Abramov has stated in previous issues on the create-react-app github to be very careful about having globals that could collide with its scripts.

The steps above fixed everything for me.

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

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.

重新安装了 node.js并将npm root -g命令给出的路径添加到我的路径变量中以使其正常工作。

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