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

新手上路,请多包涵

我正在尝试在 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

原文由 Uğur Yeşilyurt 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 682
2 个回答

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

原文由 Uğur Yeşilyurt 发布,翻译遵循 CC BY-SA 3.0 许可协议

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

原文由 Wathsala Karunathilake 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题