question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tinybase not compatible with metro in react-native

See original GitHub issue

Describe the bug

Hello, I’m trying to use tinybase for a project with react-native and I keep getting this error:

While trying to resolve module `tinybase` from file `---path---\App.tsx`, the package `--path--\node_modules\tinybase\package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`--path---\node_modules\tinybase\index`. Indeed, none of these files exist.:.....

In my opinion, looks like metro has issues with the way the package is exported in package.json and cannot resolve the correct path.

Your Example Website or App

React native is not an option in stackblitz

Steps to Reproduce the Bug or Issue

  1. Initialize a react native app
  2. Install tinybase
  3. Import and interact with tinybase

Expected behavior

I would expect tinybase to work similar to how it does in a react or next app, with webpack.

Screenshots or Videos

No response

Platform

  • OS: [macOS, Windows, Linux]
  • Browser: [Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
jamesgpearcecommented, Apr 15, 2022

OK, fixed. Please update to v1.3.2. This adds a "react-native" field to package.json that allows Metro to find the file directly (since it doesn’t currently support exports).

image

The ui-react library works too! - because it doesn’t rely on the HTML DOM. But Note that until Metro fixes https://github.com/facebook/metro/issues/670 you will still have to be slightly creative and reference it explicitly from the lib folder directly:

image

Have fun and let me know how it goes!

0reactions
jamesgpearcecommented, May 3, 2022

Oh no! I wonder if you can use tsconfig to force it to resolve the .d.ts at that path? Or try some explicit things in the typesVersions field in package.json. Happy to merge in anything that fixes it until https://github.com/facebook/metro/issues/670 happens.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Native IOS real device does not connect to Metro server
I think that this was the main problem in my situation. Turn off the metro, the app usually starts (because the native app...
Read more >
This Week In React #120: use RFC, Sandpack, Storybook ...
In a React context, the libraries used (Helmet, CSS-in-JS, Redux...) must be compatible for streaming to be effective. Storybook - First- ...
Read more >
TinyBase (@tinybasejs) / Twitter
The reactive data store for local‑first apps. In your JavaScript app. tinybase.org Joined January 2022 ... v1.3.2 Support for TinyBase in React Native....
Read more >
This Week In React #100: React 18, React-Native 0.68, Redwood ...
Hi everyone! Lots of things happened during my ski holiday We cover React 18, React-Native 0.68, and 2 weeks of full of news....
Read more >
react native metro bundler not starting : Solved Solution
Recently a lot of programmers are having issue on using a react native init application to start an app all because of a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found