Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to resolve module "geotiff" when importing in React native #126

Open
JoBerkner opened this issue Jan 22, 2020 · 7 comments
Open

Unable to resolve module "geotiff" when importing in React native #126

JoBerkner opened this issue Jan 22, 2020 · 7 comments

Comments

@JoBerkner
Copy link

JoBerkner commented Jan 22, 2020

I think this issue is more React Native related, but perhaps somebody knows how to solve this. I am building a React Native app using Expo and installed geotiff using:

npm install geotiff --save

However, when I try to import it in my React Native project:

import GeoTIFF from 'geotiff'

I am getting the error:

The development server returned response error code: 500 [...] Unable to resolve module "geotiff" from "{path to component}": geotiff could not be found within the project.

However, when trying to get it from command line it works:

> node
> const GeoTIFF = require('geotiff')
> GeoTIFF
{ GeoTIFF: [Getter],
  MultiGeoTIFF: [Getter],
  fromUrl: [Getter],
  fromArrayBuffer: [Getter],
  fromFile: [Getter],
  fromBlob: [Getter],
  fromUrls: [Getter],
  Pool: [Getter] }

Does anybody know how to resolve this? I tried the solution that was provided in #46, but it did not change anything.

#46

@constantinius
Copy link
Member

Unfortunately I do not have any experience with React Native or Expo. Typically the bundlers find the library or can be tweaked to find it.

@philip-firstorder
Copy link

philip-firstorder commented Apr 13, 2020

With "geotiff": "1.0.0-beta.10" I have the same problem in Angular 9, but fixed it by importing like this:

import * as GeoTiff from 'geotiff';

I also get this warning when compiling for Angular Universal for SSR, could be related:

WARNING in ./node_modules/geotiff/dist-browser/main.js 1:292-296
Critical dependency: the request of a dependency is an expression

@PacoDu
Copy link
Contributor

PacoDu commented Apr 13, 2020

I also get this warning when compiling for Angular Universal for SSR, could be related:

WARNING in ./node_modules/geotiff/dist-browser/main.js 1:292-296
Critical dependency: the request of a dependency is an expression

This is due to the browser field in package.json that I've added in #131. It is not properly defined and should be fixed by #144.

Can you tell me if the PR fixes the issue for you Angular build ? Note that you need to add the threads-plugin to your webpack config if you are using GeoTIFF.Pool (see: https://github.com/geotiffjs/geotiff.js/pull/144/files#diff-04c6e90faac2675aa89e2176d2eec7d8R301-R315).

It may also fixes the import issue depending on the configuration of your project.

@constantinius
Copy link
Member

@JoBerkner @PacoDu do you think we can close this issue now? (I'm not a React native user)

@JoBerkner
Copy link
Author

@constantinius yes, I think the solution provided by @philip-firstorder works (did not test it though, but I know of an exact same issue with another library in React Native). I will test it today one .ore time once I am on my PC.

@jsbroks

This comment has been minimized.

@MatheusRBarbosa
Copy link

I'm with the same issue with nextjs 14. I already tried the @philip-firstorder solution and it not worked =(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants