0

我是反应原生的新手。导入 react-native-calendar-picker 后出现以下错误:

 ERROR    [Error: InternalError Metro has encountered an error: While trying to resolve module `react-native-calendar-picker` from file `C:\Users\Name\Project\app\App\Components\DatePickerPopup\index.js`, the package `C:\Users\Name\Project\app\node_modules\react-native-calendar-picker\package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`C:\Users\Name\Project\app\node_modules\react-native-calendar-picker\CalendarPicker`. Indeed, none of these files exist:

  * C:\Users\Name\Project\app\node_modules\react-native-calendar-picker\CalendarPicker(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.svg|.native.svg|.svg)
  * C:\Users\Name\Project\app\node_modules\react-native-calendar-picker\CalendarPicker\index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.svg|.native.svg|.svg): C:\Users\name\Project\app\node_modules\metro\src\node-haste\DependencyGraph.js (376:17)

  374 |
  375 |         if (error instanceof InvalidPackageError) {
> 376 |           throw new PackageResolutionError({
      |                 ^
  377 |             packageError: error,
  378 |             originModulePath: from,
  379 |             targetModuleName: to]
4

1 回答 1

1

如果您已经安装了该模块,则似乎 Metro bundler 尚未重新启动。尝试重新启动捆绑程序。

于 2021-09-09T10:57:10.250 回答