Search code examples
react-nativeparse-platformback4app

Error importing Parse in React Native (using Back4App)


I am trying to setup Back4App in React native and in the tutorial it says to import Parse like so: import Parse from "parse/react-native.js". But whenever I add this line I get the Error listed below. Anyone have an idea why this would happen? Thanks.

Error: While trying to resolve module idb-keyval from file /Users/reidtaylor/Sessler2022/node_modules/parse/lib/react-native/IndexedDBStorageController.js, the package /Users/reidtaylor/Sessler2022/node_modules/idb-keyval/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/Users/reidtaylor/Sessler2022/node_modules/idb-keyval/dist/compat.cjs. Indeed, none of these files exist:

  • /Users/reidtaylor/Sessler2022/node_modules/idb-keyval/dist/compat.cjs(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
  • /Users/reidtaylor/Sessler2022/node_modules/idb-keyval/dist/compat.cjs/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx) at DependencyGraph.resolveDependency (/Users/reidtaylor/Sessler2022/node_modules/metro/src/node-haste/DependencyGraph.js:243:17) at Object.resolve (/Users/reidtaylor/Sessler2022/node_modules/metro/src/lib/transformHelpers.js:129:24) at resolve (/Users/reidtaylor/Sessler2022/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:33) at /Users/reidtaylor/Sessler2022/node_modules/metro/src/DeltaBundler/traverseDependencies.js:412:26 at Array.reduce () at resolveDependencies (/Users/reidtaylor/Sessler2022/node_modules/metro/src/DeltaBundler/traverseDependencies.js:411:33) at processModule (/Users/reidtaylor/Sessler2022/node_modules/metro/src/DeltaBundler/traverseDependencies.js:140:31) at async addDependency (/Users/reidtaylor/Sessler2022/node_modules/metro/src/DeltaBundler/traverseDependencies.js:230:18) at async Promise.all (index 33) at async processModule (/Users/reidtaylor/Sessler2022/node_modules/metro/src/DeltaBundler/traverseDependencies.js:198:5)

Solution

  • I ended up fixing the issue by downgrading the version of the parse package to 3.4.0. Apparently others were having this problem as well.