[英]Requiring unknown module “ReactPerf” while integrating React Native with existing Android app
我正在嘗試集成最新的React Native構建,並且我遇到了錯誤。 這是我的項目設置:
在app的build.gradle中,我導入react-native 0.24.1:
dependencies {
...
compile 'com.facebook.react:react-native:0.24.1'
}
項目的build.gradle指向Git子模塊中的React Native:
allprojects {
repositories {
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$projectDir/../MyGitSubmodule/AwesomeProject/node_modules/react-native/android"
}
}
}
如在文檔中描述的我另有集成在這里 ,並在該文檔描述的升級在git的子模塊RN 這里 。 我已將堆棧跟蹤上傳到此pastebin鏈接 。 要總結堆棧跟蹤,因為格式化很難閱讀,這些是亮點:
基本上,它抱怨模塊ReactPerf
是必需的,但它不存在。
僅供參考, ReactPerf
模塊: https : ReactPerf
。
從邏輯上講,我們只需要告訴react-native來安裝這個東西。
棘手的部分是,如果我們這樣做:
npm install react-addons-perf
,然后我們將它安裝在react-native
依賴項的“外部”。 因此,它會抱怨react-addons-perf
需要react
包。
解決方案是我們需要聲明這個依賴“inside”react-native包。 換一種說法:
打開node_modules/react-native/package.json
。 你會找到
...
"dependencies": {
"absolute-path": "^0.0.0",
"art": "^0.10.0",
"babel-core": "~6.4.5",
"babel-plugin-external-helpers": "~6.4.0",
...
"react": "^0.14.5"
...
}
所以,我們需要做的就是為這些添加react-addons-perf
。
...
"dependencies": {
"absolute-path": "^0.0.0",
"art": "^0.10.0",
"babel-core": "~6.4.5",
"babel-plugin-external-helpers": "~6.4.0",
...
"react": "^0.14.5",
"react-addons-perf": "^0.14.5", // ADD THIS LINE FOR ReactPerf module
...
}
然后, npm install
。
根據我的經驗,其余的錯誤,如Requiring module "8"
也將消失。
它對我有用,希望它也適合你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.