Search code examples
javascriptnode.jsnpmopenlayers

How to host openlayer examples on a local server?


I have to use an older version of OpenLayers (4.6.2). The examples are really useful to try out and to copy paste from. However the web page with examples contains the latest version.

Is it possible to host OpenLayers examples locally?

What I tried:

  • checking out 4.6.2 version
  • npm install
  • npm run-script start --> Starts a server, but examples won't work
  • npm run-script transform --> Throws an error like below

    npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! openlayers@4.6.2 lint: eslint tasks test src examples transforms "--fix" npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the openlayers@4.6.2 lint script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    npm ERR! A complete log of this run can be found in: npm ERR! D:\Users\liptak\AppData\Roaming\npm-cache_logs\2018-08-07T14_58_46_839Z-debug.log npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! openlayers@4.6.2 transform: npm run changecase-src && npm run transform-src && npm run transform-examples && npm run transform-test && npm run lint -- --fix npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the openlayers@4.6.2 transform script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    npm ERR! A complete log of this run can be found in: npm ERR! D:\Users\liptak\AppData\Roaming\npm-cache_logs\2018-08-07T14_58_46_895Z-debug.log

I suppose it would need a specific version of Node and NPM to build, but I have no idea, how to find that out.

Can someone help me out here? Do I have to build OpenLayers, or there is a simpler solution to start up the examples?


Solution

  • You may try to build examples locally but instead of struggling with the local build system, you can simply access to old versions of OpenLayers API and examples.

    To illustrated, for v4.6.5 you can use http://openlayers.org/en/v4.6.5/examples/ and http://openlayers.org/en/v4.6.5/apidoc/

    You just need to change in the url the OpenLayers version to get it