react-native:无法识别命令"run-android".可能是npm install引起的 [英] react-native: Command `run-android` unrecognized. Maybe caused by npm install
问题描述
最近,当我安装本机包时,我开始遇到此问题(例如: react-navigation
)进入我的项目,一堆软件包被删除(包括我认为的react,react-native).
Recently I started getting this issue, when I install a react-native package
(eg: react-navigation
) into my project, a whole bunch of packages are been removed (including react, react-native i think).
然后当我尝试运行命令" run-android
"时,它说它无法识别.
And then when i try to run command "run-android
", it says it doesn't recognize.
我最近更新到了最新的 npm
和 react-native-cli
." npm install
"有什么问题吗?还是 react-native
?
I recently updated to the latest npm
and react-native-cli
. Is it something wrong with "npm install
"? or react-native
?
node version: 8.1.2 <br/>
react-native-cli: 2.0.1 <br/>
react-native: 0.45.1 <br/>
react-navigation: 1.0.0-beta.11
以下是重新创建的步骤:
Below are the steps to re-create:
步骤1-创建项目.
Step 1 - Create project.
步骤2-运行"run-android"命令(有效).
Step 2 - Run the "run-android" command (This works).
步骤3-将"react-native-navigation"安装到项目中.
Step 3 - Install "react-native-navigation" into project.
Notice in the image above. Seems like all the other packages are removed from the project.<br/><br/>
- 第4步-尝试再次运行"run-android"命令.(将失败,但之前曾工作过)
对这个问题是什么以及有什么解决办法的任何想法吗?
Any idea on what the issue is and any way to solve it?
推荐答案
Found the solution here.
起初运行 npm install
无效,但是随后删除 package-lock.json
文件并运行 npm install
即可工作.
At first running npm install
didn't work, but then, deleting the package-lock.json
file and running npm install
did the job.
此后,我分别安装了 react-navigation
软件包,并且运行良好.
After that I installed react-navigation
package seperately and it worked fine.
这篇关于react-native:无法识别命令"run-android".可能是npm install引起的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!