简体   繁体   English

导入 react-native 社区选择器时出错

[英]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:我是 react-native 的新手,因为我使用的是 Expo 并且我必须安装 react-native 社区选择器,我使用以下命令进行安装:

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 命令进行安装:

expo install @react-native-community/picker

Here is doc这是文档

The Author renamed the library to @react-native-picker/picker .作者将库重命名为@react-native-picker/picker Please try to use it.请尝试使用它。

For details see this link.有关详细信息,请参阅链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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