0

在我将shoutem ui安装到我的项目并导入到我的ui后,我遇到了这个错误。“捆绑失败:错误:无法解析模块`react-native/Libraries/StyleSheet/ColorPropType.js”

我尝试遵循 react-native 错误页面中的建议

  1. 清除守望者手表:watchman watch-del-all
    1. 删除node_modules文件夹:rm -rf node_modules && npm install.
    2. 重置 Metro Bundler 缓存:rm -rf /tmp/metro-bundler-cache-*npm start -- --reset-cache.
    3. 移除急速缓存:rm -rf /tmp/haste-map-react-native-packager-*.
4

1 回答 1

1

版本 >= 0.58.x 时有些问题。使用以下过程或使用 react-native <0.58

创建脚本文件 fix.sh

cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js ./node_modules/react-native/Libraries/Components/View/ViewStylePropTypes.js
cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js ./node_modules/react-native/Libraries/StyleSheet/ColorPropType.js
cp ./node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js ./node_modules/react-native/Libraries/Image/ImageStylePropTypes.js

并在 package.json

  {
"scripts": {
"postinstall": "sh ./fix.sh"
 },
  "dependencies": {
    "@shoutem/ui": "^0.23.12",
    "react": "16.6.3",
    "react-native": "0.58.5"
  }
 }
于 2019-07-05T10:30:48.873 回答