5

This is a question related to my other question OpenLayers/jQuery without CDN?. I was looking to copy a minimal set of files on js/css files to replace online CDNs, so that I can run a test server on localhost without internet access.

I heard from the comments that it is possible to use node.js to run a test server entirely on the localhost. This is a interesting approach. I was wondering what are the general steps, e.g. to run such a webgis server with (or that matches) typical options like OpenLayers and GeoServer?

Thanks

  • You're really asking two separate questions here: "How do I run a GIS server locally with Node.js?" and "How do I host libraries locally in my web GIS project using XYZ technology?" You can host libraries like JQuery locally with any web server, be it Apache, nginx, IIS, Node. Each of them has different methodology for doing so. One of the reasons Node was recommended to you in the other question is because it's a fairly lightweight server with easy setup so it's pretty easy to run a local server using it. You may want to edit your question to be a bit more specific for better answers. – Conor Nov 25 '14 at 22:36
  • @Conor. Actually, I mentioned nodejs because it is fairly tightly coupled with OL3 and the obvious choice for any Javascript api, imho. Your points are good though, it is lightweight and easy to setup. – John Powell Nov 25 '14 at 23:00
7

I got OL3 working locally using nodejs by following (some of) the instructions on from OL3 github repo. I did the following on Ubuntu.

1). Clone OL3 from github

git clone https://github.com/openlayers/ol3.git

2). Cd to the ol3 directory (where package.json lives) and install node dependencies

npm install

If this fails with lots of bizarre node errors (possible), run

sudo apt-get install node-js legacy

which was taken from this SO post.

3). Run the python script to setup a local server

./build.py serve

which under the hood runs tasks/serve.js, at which point, if you are lucky and have sacrificed enough goats, you will see the message,

info serve Listening on http://localhost:3000/ (Ctrl+C to stop)

4). Navigate to http://localhost:3000/examples

and you should have all the OL3 examples working locally and be able to see the uncompressed Javascript files in the sources tab of your favorite web developer console.

Looking at some of the source code, I can only take my hat off to some really impressive stuff from the OpenLayers 3 dev team.

  • You are welcome. I guess I had better try and find out why the node-js legacy bit is needed at some point. – John Powell Nov 25 '14 at 23:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.