openlayers: Error with latest version (6.7.0) when trying to run with Angular

Warning: E:\.....\node_modules\geotiff\src\compression\deflate.js depends on 'pako/lib/inflate'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: E:\.....\node_modules\geotiff\src\geotiffimage.js depends on 'txml'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: E:\.....\node_modules\geotiff\src\source\blockedsource.js depends on 'lru-cache'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

./node_modules/geotiff/src/source/client/http.js:2:0-24 - Error: Module not found: Error: Can't resolve 'http' in 'E:\.....\node_modules\geotiff\src\source\client'
Did you mean './http'?
Requests that should resolve in the current directory need to start with './'.
Requests that start with a name are treated as module requests and resolve within module directories (E:/...../src, node_modules).
If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
        - install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "http": false }

./node_modules/geotiff/src/source/client/http.js:3:0-26 - Error: Module not found: Error: Can't resolve 'https' in 'E:\.....\node_modules\geotiff\src\source\client'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "https": require.resolve("https-browserify") }'
        - install 'https-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "https": false }

./node_modules/geotiff/src/source/file.js:2:0-39 - Error: Module not found: Error: Can't resolve 'fs' in 'E:\.....\pwa\node_modules\geotiff\src\source'

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 6
  • Comments: 25 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks @ahocevar I fixed the issue. It seems I was doing the wrong import and importing all the sources:

Changed this:

import { Vector as VectorSource, XYZ } from 'ol/source';

To this:

import VectorSource from 'ol/source/Vector';
import XYZ from 'ol/source/XYZ';

@mhosman , this last solution also fix my problem !

Thanks for sharing that, @lvenchi. So the problem in OpenLayers could be fixed if geotiff.js and its dependencies (readable-stream) had the respective polyfills or fallbacks configured. readable-stream has an open issue for that already: nodejs/readable-stream#448 .

Just wanted to say that geotiff v1.0.6 just dropped with a fix for this. Just removing an readding openlayers to my project got the right version, and now my project compiles with vite.

@ahocevar I got the error without using the geotiff source. Just the simplest of maps with a Tile layer and an OSM source.

Thanks guys. Anyway, adding that to the package.json doesn’t solve the problem (at least for me).