繁体   English   中英

'create-react-app' 未被识别为内部或外部命令

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

我正在尝试在 windows pc 上使用 create-react-app 命令设置反应应用程序。 我已经在我的 Mac 电脑上使用过它,而且效果很好。 但是我遇到了一个问题。 这是我在命令行上的步骤。 我错过了什么吗?

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.

npm 配置路径也像

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 变量来解决了这个问题。

如果您运行的是旧版本的节点,只需将“npx”放在命令前面即可解决此问题。

试试这个,它会正常工作。

npx create-react-app [yourProjectName]

我添加这个是因为它在谷歌上弹出,我遇到了麻烦。

我在 Windows 10 上,我在C:\中搜索了“create-react-app”,路径是C:\Users\Admin\AppData\Roaming\npm\node_modules

我将它添加到环境变量>路径中,该命令现在可以使用。

使用npx create-react-app my-app 这将解决系统路径变量的任何问题。

React GitHub 文档也建议了这一点。 在这里阅读

首先检查您的节点版本。 如果您的节点版本是 8 或更高版本,那么 8 然后使用
'npx 创建反应应用程序我的应用程序'

在上面的版本中,我们只需要更改一个单词 npx

你不需要做其他事情。 我希望这能帮到您

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

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

我也遇到了同样的问题,但我通过以下步骤解决了

  1. 使用命令npm root -g检查您的全局目录
  2. 检查文件夹,它是否包含已安装软件包的.cmd
  3. 如果是,请复制文件夹的路径并放入用户变量的路径。

谢谢

我必须将 c:\node_modules.bin 添加到我的路径中才能运行 create-react-app

搜索 create-react-app 并在您的路径中使用它。

  • 运行: npx install create-react-app nameOfYourFolder而不是npm install create-react-app nameOfYourFolder (npx 带有 npm 5.2+ 及更高版本)
  • 然后: cd nameOfYourFolder
  • 然后运行: npm start

你可以在这里找到更多的 React 文档

TERMINAL执行以下操作:

  • cd myReactApp
  • npx create-react-app .

这应该工作!

用户执行命令

npx 创建反应应用程序我的应用程序

尽管我遇到了同样的问题

npm install create-react-app --global

后来试了

npm init react-app projectname

这对我有用,它创建了一个 React 项目。 这也有效

npx create-react-app projectname

这个问题主要是由两个原因引起的:

  1. 路径变量问题
  2. npm 版本问题

将 C:\Users\ugur\AppData\Roaming\npm 添加到 Windows PATH 变量并将 npm 版本升级到 5.5.1

这是一个windows变量路径问题,我最近遇到了同样的问题,以下是问题的可能根本原因,通过nvm(节点版本管理器)安装节点,以便在运行npm install -g create-react-app后解决这种情况下的问题在我的情况下, npm install -g create-react-app到达位置C:\Users\pc\AppData\Roaming\npm将 create-react-app 复制到C:\Users\pc\AppData\Roaming\nvm\v12.18.3和还将 node_module 文件夹中名为 create-react-app 的文件夹移动到您在 nvm 下使用的特定版本,之后您应该能够在没有问题的情况下使用 create-react-app 。 我希望这会对某人有所帮助

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

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

我通过以下步骤解决了我的问题

  1. npm install -g create-react-app 全局安装 react app
  2. create-react-app version 检查它是否已安装,如果已安装,则版本是什么。
  3. 创建反应应用程序 [名称]
  4. cd [名称]
  5. npm 开始

通过全局安装 react 可以解决那些即使设置了环境变量也没有得到的错误。 npm i -g create-react-app 现在将安装模块。

如果上述解决方案不起作用,试试这个,它将 100% 起作用

0)首先安装包“npm create-create-app -g”或“yarn add create-react-app”然后

1)打开cmd并输入“npm root -g”这个命令将为您提供全局包的node_model目录路径

2) 仅将该路径复制到 npm 目录,例如 C:\Users\vchaudhari\AppData\Roaming\npm

3)在windows中打开环境变量,并在其中保存该命令。

4)关闭当前cmd并打开新cmd并使用命令“create-react-app demoapp”

5)享受:-)

环境节点 -v: v8.9.3 npm -v:4.6.1 yarn --version (如果你使用 Yarn): npm ls react-scripts (如果你还没有弹出): C:\Users\chacker\my-react -app>npm ls react-scripts my-react-app@1.0.0 C:\Users\chacker\my-react-app `-- (empty) 然后,指定:

操作系统:windows 7 浏览器和版本(如果相关):重现步骤(在此处写下您的步骤:)

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 创建-react-app my-app

此命令需要 Expo-CLI。 如果您想节省时间,我向您推荐 Node.js 命令提示符,它会自动添加必要的依赖项。

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

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

仍有此问题的人,请转到 C:\Users\user\AppData\Roaming\npm- 检查 .cmd 是 create-react-app 还是 creact-react-native-app。

我的是后者。

另外,请确保您没有安装两个不同的版本。

我试图在我的 PC 上使用 Windows PowerShell 创建一个应用程序。 我尝试相应地更新和设置环境变量。 但在我遵循这些步骤之前,没有任何东西对我有用。

  1. npm install create-react-app
  2. npx 创建反应应用程序

然后它开始工作。 按相同顺序使用这些命令。

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

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

文档说: npm init react-app my-app

参考: https ://github.com/facebook/create-react-app

尝试这个。

npm 卸载 -g create-react-app

或者

yarn 全局删除 create-react-app

它将解决问题

我遇到这个问题的原因可能有所不同,但我将其列为答案,以防其他人发现这个问题而且它有助于他们。

我刚刚解决了这个问题:

  1. 删除不必要的全局变量

    • npm list -g --depth=0
    • npm uninstall -g <args>
  2. 正在删除package-lock.json

  3. rm -rf node_modules
  4. npm install

我的想法让我收到了这个问题:

我正在一个游乐场分支上开发并且运行了一些不正确的命令,例如npm install --prefix client && npm run test --prefix client ,来自错误的目录。

我可能用package-lock.json创建了一些问题,然后当我重新安装时,有一些babel-eslint全局问题。

Dan Abramov在先前的问题中已经在create-react-app github中声明要非常小心有可能与其脚本冲突的全局变量。

上面的步骤为我修复了一切。

我通过卸载 create-react-app 解决了这个问题:

npm uninstall create-react-app

然后使用以下命令安装:

npm install -g create-react-app

我按照以下步骤解决了问题

1) 打开 Node.js 命令提示符

2)然后输入“npm install create-react-app -g”(g 表示全局访问)命令安装 create-react-app

3)然后输入“npm install create-react-native-app -g”(g 表示全局访问)命令安装 create-react-native-app

按照步骤 #2 使用 create-react-app

仅当您想使用 create-react-native-app 时才执行第 3 步,否则它是可选的。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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