导入反应本地社区选择器时出错

时间:2020-07-18 17:50:28

标签: javascript reactjs react-native

我是React-native的新手,因为我正在使用Expo,并且必须安装react-native社区选择器,所以我使用以下命令进行安装:

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

之后,我像这样导入它:

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

但是出现以下错误:

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:

2 个答案:

答案 0 :(得分:2)

您需要使用expo命令进行安装:

expo install @react-native-community/picker

Here is doc

答案 1 :(得分:1)

作者将库重命名为 @react-native-picker/picker。请尝试使用它。

有关详细信息,请参阅 this 链接。