首页 > 解决方案 > 找不到模块:无法解析 'node_modules\react-native\Libraries\Animated\src\components\AnimatedImage.js' 中的 '../../../Image/Image'

问题描述

当我开始运行 expo 时出现错误。我正在尝试启动一个正在进行的项目,但无法找出问题所在。

找不到模块:无法解析 'node_modules\react-native\Libraries\Animated\src\components\AnimatedImage.js' 中的 '../../../Image/Image'

包.json

"dependencies": {
"@react-native-community/async-storage": "^1.11.0",
"@react-native-community/blur": "^3.6.0",
"@react-native-community/datetimepicker": "2.6.1",
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/drawer": "^5.9.0",
"@react-navigation/native": "^5.7.3",
"@react-navigation/stack": "^5.9.0",
"@terrylinla/react-native-sketch-canvas": "^0.8.0",
"axios": "^0.19.2",
"expo": "~38.0.9",
"expo-splash-screen": "^0.5.0",
"expo-status-bar": "^1.0.0",
"expo-updates": "~0.2.10",
"formik": "^2.1.5",
"i18n-js": "^3.7.1",
"lodash.memoize": "^4.1.2",
"moment": "^2.27.0",
"native-base": "^2.13.13",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "~0.62.2",
"react-native-animated-nav-tab-bar": "^3.0.3",
"react-native-check-box": "^2.1.7",
"react-native-cn-richtext-editor": "^1.0.42",
"react-native-datepicker": "^1.7.2",
"react-native-dialog-component": "^0.2.17",
"react-native-dropdown-picker": "^3.1.11",
"react-native-dropdownalert": "^4.3.0",
"react-native-elements": "^2.2.1",
"react-native-face-pile": "^1.9.0",
"react-native-fast-image": "^8.3.2",
"react-native-gesture-handler": "^1.7.0",
"react-native-keyboard-aware-scroll-view": "^0.9.2",
"react-native-localize": "^1.4.1",
"react-native-masked-text": "^1.13.0",
"react-native-material-ui": "^1.30.1",
"react-native-modal": "^11.5.6",
"react-native-modal-datetime-picker": "^8.9.3",
"react-native-paper": "^4.0.1",
"react-native-reanimated": "^1.13.0",
"react-native-responsive-screen": "^1.4.1",
"react-native-safe-area-context": "^3.1.4",
"react-native-screens": "^2.10.1",
"react-native-snap-carousel": "^4.0.0-beta.5",
"react-native-unimodules": "~0.10.1",
"react-native-vector-icons": "^7.0.0",
"react-native-view-more-text": "^2.1.0",
"react-native-web": "~0.11.7",
"react-native-wechat": "^1.9.12",
"react-redux": "^7.2.1",
"redux": "^4.0.5",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"yup": "^0.29.3"}

标签: react-native

解决方案


看来您正在使用react-native-web但最终依赖于react-native文件node_modules\react-native\Libraries\Animated\src\components\AnimatedImage.js

您应该根据react-native-web 文档正确配置您的 webpack 配置:

// webpack.config.js
module.exports = {
  // ...the rest of your config

  resolve: {
    alias: {
      'react-native$': 'react-native-web'
    }
  }
}

推荐阅读