geotiffjs / geotiff.js

geotiff.js is a small library to parse TIFF files for visualization or analysis. It is written in pure JavaScript, and is usable in both the browser and node.js applications.
https://geotiffjs.github.io/
MIT License
880 stars 184 forks source link

Error: Cannot find module 'babel-runtime/helpers/possibleConstructorReturn' #74

Open pilarArr opened 5 years ago

pilarArr commented 5 years ago

I'm using geotiff on a meteor app. I get this error when deploying but not when running on development mode.

The geotiff version I'm using is 1.0.0-beta.6 I'm not using babel-runtime because meteor updated to babel 7 some time ago. So I'm using @babel/runtime 7.1.5. Should I install babel-runtime as well ?

Error: Cannot find module 'babel-runtime/helpers/possibleConstructorReturn'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/built_app/programs/server/npm/node_modules/geotiff/dist/geotiff.js:8:35)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/built_app/programs/server/npm/node_modules/geotiff/dist/main.js:7:16)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at npmRequire (/built_app/programs/server/npm-require.js:133:10)
    at Module.useNode (packages/modules-runtime.js:664:18)
constantinius commented 5 years ago

Hi @pilarArr

Thanks for reporting this issue. I guess you have two options: you can either use the older babel-runtime or use the source files directly: import GeoTIFF from 'geotiff/src/main';

pilarArr commented 5 years ago

Hi @constantinius ! Thanks for your fast reply. I've tried importing directly from source files and I get this error:

project/folder/node_modules/geotiff/src/main.js:1
(function (exports, require, module, __filename, __dirname) { export * from './geotiff';
SyntaxError: Unexpected token export
     at createScript (vm.js:80:10)
     at Object.runInThisContext (vm.js:139:10)
     at Module._compile (module.js:616:28)

When installing the older babel-runtime it works, but I'm going to keep trying with importing from source. I would rather not install the older babel-runtime if I can, because I would need to have both installed since meteor uses babel 7

constantinius commented 5 years ago

Ah, okay, so this does not work without transpiling. We currently use a webpack based approach using babel-loader. I guess the whole toolchain is based on an older version of babel. This babel setup is already a source of pain, I guess it needs some attention.

pilarArr commented 5 years ago

@constantinius I'll be finally using the older babel-runtime. I can close the issue if you want.

constantinius commented 5 years ago

@pilarArr Alright, good to know. I think we can leave this open, I'll comb through the issues when I revise the babel setup.

wshaver commented 5 years ago

Had a similar issue with a fresh install for a node based project. Needed to install the dev dependencies in the /node_modules/geotiff directory.

bmulcahy commented 5 years ago

@wshaver Care to share your setup?

I am just using npm install and then import GeoTIFF from 'geotiff' and I received this

×
TypeError: Cannot read property 'fromUrl' of undefined
Map.componentDidMount
D:/Projects/openlayers-react-simple/src/components/map.js:18
  15 | class Map extends React.Component {
  16 |   componentDidMount() {
  17 | 
> 18 |     GeoTIFF.fromUrl(geotiffURL)
  19 |     .then(tiff => { 
  20 |       const image = tiff.getImage();
  21 |       const width = image.getWidth();

then I tried import { GeoTIFF } from 'geotiff/dist/geotiff' and received this

×
TypeError: geotiff_dist_geotiff__WEBPACK_IMPORTED_MODULE_14__.GeoTIFF.fromUrl is not a function

then I tried import { GeoTIFF } from 'geotiff/src/main'

and received this

Failed to compile
./node_modules/geotiff/src/pool.js
Attempted import error: './decoder.worker' does not contain a default export (imported as 'Worker').
bmulcahy commented 5 years ago

Ok So I did get it working with

import * as GeoTIFF from 'geotiff/src/main';