I am trying to implement https://github.com/andpor/react-native-sqlite-storage into my react native project (for Android).
This is my version of React Native:
"react-native": "0.64.1"
and this is my step:
npm install --save react-native-sqlite-storage
I presumed that I don't need extra steps because I have >0.6 version of React Native. So I decided to code something with that library. I make import
import SQLite from 'react-native-sqlite-storage';
and I received that error:
[Info] 06-07 09:00:30.160 6927 6983 E ReactNativeJS: { [Error: InternalError Metro has encountered an error: While trying to resolve module `react-native-sqlite-storage` from file `c:\Users\karol.wisniewski\happybaby\HappyBaby\app\components\Test\HomeScreen.component.js`, the package `c:\Users\karol.wisniewski\happybaby\HappyBaby\node_modules\react-native-sqlite-storage\package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`c:\Users\karol.wisniewski\happybaby\HappyBaby\node_modules\react-native-sqlite-storage\sqlite.js`. Indeed, none of these files exist:
06-07 09:00:30.160 6927 6983 E ReactNativeJS:
06-07 09:00:30.160 6927 6983 E ReactNativeJS: * c:\Users\karol.wisniewski\happybaby\HappyBaby\node_modules\react-native-sqlite-storage\sqlite.js(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
06-07 09:00:30.160 6927 6983 E ReactNativeJS: * c:\Users\karol.wisniewski\happybaby\HappyBaby\node_modules\react-native-sqlite-storage\sqlite.js\index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx): c:\Users\karol.wisniewski\happybaby\HappyBaby\node_modules\metro\src\node-haste\DependencyGraph.js (436:17)
06-07 09:00:30.160 6927 6983 E ReactNativeJS:
06-07 09:00:30.160 6927 6983 E ReactNativeJS: [0m [90m 434 |[39m[0m
06-07 09:00:30.160 6927 6983 E ReactNativeJS: [0m [90m 435 |[39m [36mif[39m (error [36minstanceof[39m [33mInvalidPackageError[39m) {[0m
06-07 09:00:30.160 6927 6983 E ReactNativeJS: [0m[31m[1m>[22m[39m[90m 436 |[39m [36mthrow[39m [36mnew[39m [33mPackageResolutionError[39m({[0m
06-07 09:00:30.160 6927 6983 E ReactNativeJS: [0m [90m |[39m [31m[1m^[22m[39m[0m
06-07 09:00:30.160 6927 6983 E ReactNativeJS: [0m [90m 437 |[39m packageError[33m:[39m error[33m,[39m[0m
06-07 09:00:30.160 6927 6983 E ReactNativeJS: [0m [90m 438 |[39m originModulePath[33m:[39m [36mfrom[39m[33m,[39m[0m
06-07 09:00:30.160 6927 6983 E ReactNativeJS: [0m [90m 439 |[39m targetModuleName[33m:[39m to[0m]
06-07 09:00:30.160 6927 6983 E ReactNativeJS: preventSymbolication: true,
06-07 09:00:30.160 6927 6983 E ReactNativeJS: line: 33240,
06-07 09:00:30.160 6927 6983 E ReactNativeJS: column: 26,
06-07 09:00:30.160 6927 6983 E ReactNativeJS: sourceURL: 'http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.happybaby&modulesOnly=false&runModule=true' }
I found a solution here However, this package itself specifies a `main` module field that could not be resolved, my metro.config.js is looking like this:
module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
resolver: {
sourceExts: ['jsx', 'js', 'ts', 'tsx']
},
};
but I still have the same error.
Do u have any solutions for this or maybe I made a mistake during configuration this library or something else?