在研究如何模拟AsyncStorage
进行测试时,我发现应该使用react-community
版本,而不是从react-native
导入(尽管从react-native
导入)似乎没有任何警告或其他任何情况都可以正常工作。
yarn add @react-native-community/async-storage
很好,但是react-native link @react-native-community/async-storage
无法正常工作,所以我在某个地方跟随了一个答案并运行了react-native-git-upgrade
,然后我就可以链接了。
但是,现在我的应用无法运行:
error: bundling failed: Error: Unable to resolve module `react-native/Libraries/Components/View/ViewStylePropTypes` from `/Users/TuzMacbookPro2017/Development/QMG-local/APPS/ELECTRO/node_modules/react-native-reanimated/src/createAnimatedComponent.js`: Module `react-native/Libraries/Components/View/ViewStylePropTypes` does not exist in the Haste module map
This might be related to https://github.com/facebook/react-native/issues/4968
我在互联网上看到PropTypes
(我从不使用自己)在某些依赖项中被使用,但已被弃用或移动。当然,它之前没有任何问题。
以下是我尝试修复的各种方法,但无济于事:
npm update
npm audit fix
-说“ react”和“ react-native”缺失,所以:npm i
npm audit fix
-运行sudo npm cache verify
rm -rf node_modules && yarn install && rm -rf $TMPDIR/react* && npm start --reset-cache
如果有什么用,这是我的package.json
文件
{
"name": "Electro",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"eject": "expo eject",
"test": "node ./node_modules/jest/bin/jest.js --watchAll"
},
"jest": {
"preset": "jest-expo",
"testEnvironment": "node"
},
"dependencies": {
"@expo/samples": "2.1.1",
"@react-native-community/async-storage": "^1.3.4",
"expo": "^32.0.0",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native": "^0.59.6",
"react-native-elements": "^1.1.0",
"react-native-geocoding": "^0.3.0",
"react-native-global-font": "^1.0.2",
"react-native-indicators": "^0.13.0",
"react-native-keyboard-aware-scrollview": "^2.0.0",
"react-native-material-dropdown": "^0.11.1",
"react-native-render-html": "^4.1.2",
"react-native-uuid": "^1.4.9",
"react-navigation": "^3.9.1",
"react-redux": "^6.0.1",
"redux": "^4.0.1",
"redux-test-utils": "^0.3.0",
"redux-thunk": "^2.3.0",
"sugar": "^2.0.6"
},
"devDependencies": {
"babel-preset-expo": "^5.0.0",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.12.1",
"jest": "^24.8.0",
"jest-expo": "^32.0.0",
"jsdom": "^14.1.0",
"mock-async-storage": "^2.1.0",
"react-test-renderer": "^16.8.6",
"redux-mock-store": "^1.5.3"
},
"private": true,
"rnpm": {
"assets": [
"./assets/fonts"
]
}
}
有人知道如何让我的应用再次运行吗??? (即使还原最后的提交也不起作用!我将尝试降级本机响应...)
答案 0 :(得分:0)
通过还原提交,最终我能够使我的应用再次运行,然后将react-native
的版本由package.json
更改回0.57