首页 > 解决方案 > 当我运行“npx react-native init AwesomeProject”时,我得到“react-native”未被识别为内部或外部命令

问题描述

我已经使用巧克力安装了节点和 jdk8。

当我遵循官方指南“设置开发环境 - > React Native ClI Quick start for 'Windows & Android'”时,我在运行npx react-native init AwesomeProject命令时收到以下错误:

'react-native' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code 1
npm ERR! path E:\UOG\React_Native_Projects\MyFirstApp
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c react-native init AwesomeProject

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Muhammad Suleman\AppData\Local\npm-cache\_logs\2021-01-23T09_10_07_360Z-debug.log

标签: react-nativenpmreact-native-android

解决方案


运行此命令

npm install -g react-native-cli

之后,只需将您的 npm 路径添加到环境变量中的系统变量

C:\Users\您的用户名\AppData\Roaming\npm


推荐阅读