简体   繁体   中英

Unable to resolve "react-native-paper/lib/typescript/src/components/MaterialCommunityIcon" from "screens\SignUpScreen.js"

I run npm start or expo start -c to start with an empty cache and so far so good, but then when I tried to run the android simulator I get the error below

Unable to resolve "react-native-paper/lib/typescript/src/components/MaterialCommunityIcon" from "screens\SignUpScreen.js" Failed building JavaScript bundle.

I've tried deleting the node_modules, updating Expo SDK as several others tried too but nothing so far...

Here's my package.json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
  "start": "expo start",
  "android": "expo start --android",
  "ios": "expo start --ios",
  "web": "expo start --web",
  "eject": "expo eject"
},
"dependencies": {
  "@react-native-community/masked-view": "0.1.6",
  "@react-navigation/material-bottom-tabs": "^5.2.2",
  "expo": "^37.0.0",
  "react": "16.9.0",
  "react-dom": "16.9.0",
  "react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
  "react-native-elements": "^2.0.0",
  "react-native-gesture-handler": "~1.6.0",
  "react-native-paper": "^3.10.1",
  "react-native-reanimated": "~1.7.0",
  "react-native-safe-area-context": "0.7.3",
  "react-native-screens": "~2.2.0",
  "react-native-vector-icons": "^6.6.0",
  "react-native-web": "^0.11.7",
  "react-navigation": "^4.3.9",
  "react-navigation-stack": "^2.5.1"
},
"devDependencies": {
  "babel-preset-expo": "^8.1.0",
  "@babel/core": "^7.8.6"
},
  "private": true
}

Any ideas?

I took a second look at my imports on SignUpScreen.js and found this import:

import { accessibilityProps } from 'react-native-paper/lib/typescript/src/components/MaterialCommunityIcon';

Which was causing the issue, removed it and now everything works.

Worked for me too!

Removing:

import { black } from "react-native-paper/lib/typescript/src/styles/colors";

and then reload your biuld.

I got the same error because I was using two ui's libraries both of them has common functions. material UI and react-native-paper.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM