typeorm: Why is the Typeorm require the react-native-sqlite-storage module that is not using in my project?
Issue type:
[x] question [ ] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[x] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)
Steps to reproduce or a small repository showing the problem:
Hi ~ When I using typeorm with Next.js react framework… I got the warning message like this.
./node_modules/typeorm/browser/driver/react-native/ReactNativeDriver.js Module not found: Can't resolve 'react-native-sqlite-storage' in '/Users/chicrock/Documents/projects/node_modules/typeorm/browser/driver/react-native'
I only use mysql database in my project.
why is typeorm load the react-native-sqlite-storage module unnecessary to me.
Is this bug ? or something wrong to my usage ?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 12
- Comments: 26 (6 by maintainers)
👀
I’m using next.js 9.2 with postgresql and I was affected by this too.
@marcorinck solution works without any problem
in my case this created a problem of circular dependency and rejected promise without a catch
this is the log of the problem after I start the server that DOESN’T use sql-lite…
this is a really really weird and unexpected bug…
currently on
The same happens when using typeorm in a Ionic4 project.
Look at this example project: https://github.com/coturiv/ionic4-typeorm-starter It has an install script to patch the ReactNativeDriver.js so that it does not try to require react-native-sqlite-storage.
I don’t know why this happens, but I know that TypeOrm only works with this patch in my personal Ionic4 testproject.
@chicrock Hi everyone, I found a solution for that. I have read the
package.jsonof typeorm, and found out that typeorm imports different libraries for different environment (node or browser). In some cases, we want to use database server-side, however, typeorm is seen as a client-side dependency, and it will assume it’s under browser environment and require react-native packages. To handle this, just add this into your project’spackage.json:getInitialProps is recommended to change getServerSideProps, so you can make a connection from that method. And not from the browser. https://nextjs.org/docs/api-reference/data-fetching/getInitialProps
@jmaister oh~
Next.js 9.3 or newerI gonna upgrade my Next.js. Thanks to replied