我有expo react-native项目(主要项目),并且我创建了一个纯react-native项目来与android和ios sdks连接。这就是为什么我创建了react-native-library-bridge。在这三个项目之间,我复制了“本机”软件包。
我的主项目在dependecies中有react-native程序包,对于其他react-native项目,我将react-native程序包放置到peerDependecies,但是当我将peerDependecies放置到react-native时,库函数无法识别出react-native程序包给父对象一。这就是为什么功能不起作用的原因。
这是主项目的软件包。
"dependencies": {
"sdk-wrapper": "file:../RNWrapper",
"expo": "^31.0.2",
"expo-localization": "^1.0.0",
"i18n": "^0.8.3",
"i18n-js": "^3.2.1",
"lodash": "^4.17.11",
"moment": "^2.24.0",
"native-base": "^2.11.0",
"prop-types": "^15.6.2",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",
"react-native-keyboard-aware-scroll-view": "^0.8.0",
"react-native-keyboard-spacer": "^0.4.1",
"react-native-render-html": "^4.1.2",
"react-native-simple-markdown": "^1.1.0",
"react-navigation": "^3.0.9",
"react-redux": "^6.0.0",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0",
"sentry-expo": "^1.11.1",
"socket.io-client": "^2.0.4"
},
这是RNWrapper的软件包(当我编写对本地依赖桥函数的react-native无效时)=>
"dependencies": {
"react": "^16.8.3",
"react-native": "^0.59.5",
"react-native-rn-wrapper-library": "/Users/alicancelik/Projects/RnWrapperLibrary"
},
"devDependencies": {
"@babel/core": "^7.4.3",
"@babel/runtime": "^7.4.3",
"babel-jest": "^24.7.1",
"metro-react-native-babel-preset": "^0.53.1",
"react-test-renderer": "16.8.3"
}
这是桥包=>
"peerDependencies": {
"react-native": "^0.41.2",
"react-native-windows": "0.41.0-rc.1"
}
我希望我能全力以赴地工作,但是我得到了本机反应式双重包装。顺便说一句,我尝试更改node_modules的名称更改,但它也无法正常工作。
答案 0 :(得分:0)
您可以尝试清除捕获内存并重新安装节点模块
rm -rf node_modules && npm install
rm -fr $TMPDIR/react-*
npm cache clean
npm start -- --reset-cache
这对我有用。