0

I want to import OpenLayers 5 in my NodeJS Express application, but I get an ERROR when I try to do this. I have this version: "ol": "^5.3.0"

EDIT:

I installed Babel. Now I still get the same error when I try to import in the client.js => console output: Uncaught SyntaxError: Unexpected identifier

Trisha
  • 75
  • 6

1 Answers1

1

Have you tried doing it like they explain in their documentation here ?

You cannot "require" the 'om' package like you try. You will have to use the 'import' statement instead.

Import is not supported by Node js by default. You can look at this (or this) question to learn how to use "import" with Node js.

crellee
  • 755
  • 1
  • 7
  • 17
  • Yes I have, but that doesn't work. Because then the console has the following output: Uncaught SyntaxError: Unexpected identifier – Trisha Jan 09 '19 at 15:15
  • I did this, but it still won't work with OL5. I get a different error now. Will add it to my question – Trisha Jan 09 '19 at 15:44
  • The framework should be used on the client site. I don't get what you try on the server site – crellee Jan 09 '19 at 15:56
  • Well, because nothing worked on the client side, so I started trying everything on both client and server side, because I desperately need this to work.. But I will stop trying at the server then. Thanks – Trisha Jan 09 '19 at 15:59