我正在尝试在 Windows 电脑上使用 create-react-app 命令设置 React 应用程序。
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.
npm 配置路径也是这样的
C:\Users\ugur\AppData\Roaming\npm\node_modules\create-react-app\
答案
我通过添加解决了这个问题C:\Users\ugur\AppData\Roaming\npm
到 Windows PATH 变量。