React-native won't compile because of the use of h3-js
See original GitHub issueimporting h3-js this way import * as h3 from "h3-js";
would trigger the error below:
[Sat May 08 2021 16:50:27.116] ERROR Error: Requiring module "node_modules/h3-js/dist/browser/h3-js.js", which threw an exception: ReferenceError: Can't find variable: document
[Sat May 08 2021 16:50:27.132] ERROR ReferenceError: Can't find variable: document
I am wondering if this could be easily fixed? I am reading that there is a node version of h3-js, how can I import it instead of the browser version?
I tried to only import the function I was using at the time but I am still getting the same error
import {geoToH3} from 'h3-js';
I think the error is pointing to this code here in h3-js
var readAsync;
{
if (document.currentScript) {
scriptDirectory = document.currentScript.src;
}
if (scriptDirectory.indexOf("blob:") !== 0) {
scriptDirectory = scriptDirectory.substr(0, scriptDirectory.lastIndexOf("/") + 1);
} else {
scriptDirectory = "";
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:13
Top Results From Across the Web
can't compile and run my react native app #25936 - GitHub
I just can't compile and run my react native app, and I'm getting this message : FAILURE: Build failed with an exception.
Read more >Troubleshooting Native Modules · React Native for Windows + ...
My native method isn't being hit in the VS debugger. If your method isn't being hit in the VS debugger, something is blocking...
Read more >Failure to compile on react native - javascript - Stack Overflow
So I've been trying to run my react native code but it keeps ... This method is required in order to use this...
Read more >React Native compile time errors not resulting in run time failure
I've configured a React Native app via the react-native-cli using the TypeScript template and have been working in the codebase for a few ......
Read more >React Native: Why and How to Build Your Native Code in Go
We use React Native packages that deal with the native parts of each OS, because core React Native hasn't got to it yet,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
With Deno’s recent support for npm packages, you may now use a regular import like
Easy enough, but non-standard and won’t help people on other runtimes (and not even Deno Deploy as the feature is experimental). It would be great if h3-js could simply get rid of the
document
-reference.It looks like the bug on the Emscripten side (https://github.com/emscripten-core/emscripten/issues/14198) was fixed as of November of last year. Would it be possible to cut a new h3-js release with the latest emscripten, which hopefully will make this library React Native compatible?