How do I get node-osrm working?
Server: Ubuntu 14.0 I've cloned the osrm-backend git and followed these instructions: https://github.com/Project-OSRM/osrm-backend/wiki/Building-OSRM Now I need to get the node part running. I don't want to use osrm-routed because I need this to work on https. Any help would be appreciated.
@billystalnaker easiest thing to do is just use the modules we've already published for the latest release:
npm install osrm
will get you the node bindings as a regular node module, and all the pre-processing tools in node_modules/osrm/lib/binding/osrm-extract, etc.
No need to build OSRM from scratch unless you need the bleeding edge, or want to work on the code.
Once I run npm install osrm what js file do I run to get allow the server to run http requests? Thanks for that clarification.
There is no server included, you'll need to build your own using express-js or the-like. The node bindings are designed to be called from your own node code.
There is a copy of osrm-routed in node_modules/osrm/lib/bindings/osrm-routed for testing.
There's a very simple example server here:
https://github.com/Project-OSRM/osrm-backend/blob/master/example/example.js
@danpat I installed the osrm package via npm but do not see any bindings here: node_modules/osrm/lib/ There is only an index.js file
Apparently I had a version of Node.js (4) that didn't work with the version of npm I had running and so the files were not there.
ERROR: npm is known not to run on Node.js v4.2.6
Node.js 4 is supported but the specific version you're running has
a bug known to break npm. Please update to at least ${rel.min} to use this
version of npm. You can find the latest release of Node.js at https://nodejs.org/
This was helpful: https://stackoverflow.com/questions/46360567/error-npm-is-known-not-to-run-on-node-js-v4-2-6
@billystalnaker ah, yes, the Node ecosystem has lots of warts like that.
I would recommend using nvm to control it - https://stackoverflow.com/a/46361315
The Node/npm packages that come with Ubuntu tend to be fairly dated, I would avoid them.
Note that we publish OSRM modules that are compatible with Node 4 and 6, but not 8 (yet).
Thanks!
@billystalnaker Can we close this issue? If there's no actual bug in OSRM, I'll pencil this one up to "the nodejs ecosystem is messy"
Yes, that's fine by me.