osrm-backend icon indicating copy to clipboard operation
osrm-backend copied to clipboard

OSRM node bindings v6.0.0 fails to load: wrong path to binary in index.js

Open jmostaer opened this issue 6 months ago • 1 comments

Issue

When using the OSRM Node bindings v6.0.0, the module fails to load due to an incorrect path reference in lib/index.js.

Specifically, the following line in index.js attempts to load the binary from a path that does not exist:

var OSRM = module.exports = require('./binding/node_osrm.node').OSRM;

However, the binary file is actually located under a different directory:

./binding_napi_v8/node_osrm.node

This causes the following error when trying to require the package

Uncaught Error: Cannot find module './binding/node_osrm.node'

Steps to reproduce

  1. Install the OSRM Node bindings via npm:

npm install @project-osrm/[email protected]

  1. In a Node.js script, attempt to require the module:

const OSRM = require('@project-osrm/osrm');

  1. Run the script:

node script.js

You will encounter the following error:

Error: Cannot find module './binding/node_osrm.node'

  1. Replace ./binding/node_osrm.node with ./binding_napi_v8/node_osrm.node in lib/index.js to fix the error.

Specifications

  • Library version: @project-osrm/[email protected]
  • Node.js version: v22.13.0
  • Operating system: TUXEDO OS 24.04

jmostaer avatar Apr 23 '25 08:04 jmostaer