简体   繁体   中英

Error when importing react-native community picker

I'm new to react-native, since I'm using Expo and I had to install react-native community picker, I used the following command to install:

npm install @react-native-community/picker --save

After that I import it like this:

import {Picker} from '@react-native-community/picker';

But I get the following error:

While trying to resolve module `@react-native-community/picker` from file `C:\xampp\htdocs\secondtry\screens\HomeScreen3.js`, the package `C:\xampp\htdocs\secondtry\node_modules\@react-native-community\picker\package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`C:\xampp\htdocs\secondtry\node_modules\@react-native-community\picker\js\index.js`. Indeed, none of these files exist:

You need to use expo command for installing:

expo install @react-native-community/picker

Here is doc

The Author renamed the library to @react-native-picker/picker . Please try to use it.

For details see this link.

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-2025 STACKOOM.COM