Search code examples
node.jsimportnext.jsnode-modulesopenlayers

Openlayers node module only works with client side rendering. Why?


I initialized a brand new Next.js project and installed the official openlayers module (https://github.com/openlayers/openlayers) with npm in it. But as soon as I import it in one of the src js files, I get some error like this: Unexpected token 'export'

The only way I got it working is by telling Next.js to not use that src file on the server side.

I understand that it only wants to work with client side rendering.

Can anyone explain to me, why is it only working like that? What is different in this module that prevents it from using it with the default ssr settings?


Solution

  • OpenLayers got full node.js support since I posted my question, so with that it become obsolete.

    Find more about it on their GitHub repo.