Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
全局安装react-native后,尚未识别react-native命令_React Native_React Native Android_React Native Ios - Fatal编程技术网

全局安装react-native后,尚未识别react-native命令

全局安装react-native后,尚未识别react-native命令,react-native,react-native-android,react-native-ios,React Native,React Native Android,React Native Ios,我试图在一个新系统中设置react-native,完全按照编写的文档进行操作,但当我尝试点击react-native运行android时,它会说 命令react native无法识别。确保您已经运行了npm安装,并且您在react原生项目中 我已在全局安装react native,但收到此错误 有人能告诉我如何解决这个问题吗 日志如下: 0 verbose cli [ 0 verbose cli 'C:\\Program Files\\nodejs\\node.exe', 0 verbose

我试图在一个新系统中设置react-native,完全按照编写的文档进行操作,但当我尝试点击react-native运行android时,它会说

命令
react native
无法识别。确保您已经运行了
npm安装
,并且您在react原生项目中

我已在全局安装react native,但收到此错误

有人能告诉我如何解决这个问题吗

日志如下:

0 verbose cli [
0 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   'exec',
0 verbose cli   '--',
0 verbose cli   'react-native',
0 verbose cli   'react-native',
0 verbose cli   'run-android'
0 verbose cli ]
1 info using npm@7.5.1
2 info using node@v15.8.0
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 2ms
5 timing config:load:builtin Completed in 2ms
6 timing config:load:cli Completed in 2ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:C:\sheolife-rn\.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:C:\Users\info\.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:C:\Users\info\AppData\Roaming\npm\etc\npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 9ms
19 verbose npm-session e63e802460c0c690
20 timing npm:load Completed in 22ms
21 timing command:exec Completed in 226ms
22 verbose stack Error: command failed
22 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27)
22 verbose stack     at ChildProcess.emit (node:events:378:20)
22 verbose stack     at maybeClose (node:internal/child_process:1067:16)
22 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
23 verbose pkgid sheolife@0.0.1
24 verbose cwd C:\sheolife-rn
25 verbose Windows_NT 10.0.18362
26 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "exec" "--" "react-native" "react-native" "run-android"
27 verbose node v15.8.0
28 verbose npm  v7.5.1
29 error code 1
30 error path C:\sheolife-rn
31 error command failed
32 error command C:\WINDOWS\system32\cmd.exe /d /s /c react-native react-native run-android
33 verbose exit 1
试试下面的方法

打开终端1并运行这些命令

npx react-native start
npx react-native run-android
npm start
npm android
打开终端2并运行这些命令

npx react-native start
npx react-native run-android
npm start
npm android
编辑: 打开终端1并运行这些命令

npx react-native start
npx react-native run-android
npm start
npm android
打开终端2并运行这些命令

npx react-native start
npx react-native run-android
npm start
npm android

react native run androidhave添加,请检查我是否更新了答案,尝试了那些命令SNP,我仍然收到相同的错误仍然相同的错误尝试重新安装节点并react native。重新启动你的电脑