mapbox / node-or-tools

Node.js bindings for or-tools vehicle routing problems
MIT License
146 stars 48 forks source link

MbxClient.getMatrix is not a function #49

Open hopewise opened 6 years ago

hopewise commented 6 years ago

I've tried to run the example, however, I got this error:

/home/ubuntu/ortools/node-or-tools-master/example/index.js:78
MbxClient.getMatrix(locations.map(function (coord) { return { longitude: coord[0], latitude: coord[1] } }), {profile: profile}, function(err, results) {
          ^

TypeError: MbxClient.getMatrix is not a function
    at Object.<anonymous> (/home/ubuntu/ortools/node-or-tools-master/example/index.js:78:11)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.runMain [as _onTimeout] (module.js:442:10)
    at Timer.listOnTimeout (timers.js:92:15)

Process exited with code: 1

I am sure that MbxClient is initialized, and I can see it in debugger as attached snapshot: screen shot 2017-12-23 at 12 12 19 pm

As for installed dependencies versions as below: ( mapbox@0.12.0 )

ubuntu@ip-172-31-29-171:~/ortools/node-or-tools-master/example$ npm list
example@1.0.0 /home/ubuntu/ortools/node-or-tools-master/example
├── @turf/helpers@5.1.5
├── colorbrewer@1.1.0
├─┬ mapbox@0.12.0
│ ├── atob@1.1.3
│ ├─┬ geojsonhint@1.2.1
│ │ ├─┬ chalk@1.1.3
│ │ │ ├── ansi-styles@2.2.1
│ │ │ ├── escape-string-regexp@1.0.5
│ │ │ ├─┬ has-ansi@2.0.0
│ │ │ │ └── ansi-regex@2.1.1
│ │ │ ├── strip-ansi@3.0.1
│ │ │ └── supports-color@2.0.0
│ │ ├─┬ concat-stream@1.4.10
│ │ │ ├─┬ readable-stream@1.1.14
│ │ │ │ ├── isarray@0.0.1
│ │ │ │ └── string_decoder@0.10.31
│ │ │ └── typedarray@0.0.6
│ │ ├─┬ jsonlint-lines@1.7.1
│ │ │ ├── JSV@4.0.2
│ │ │ └─┬ nomnom@1.8.1
│ │ │   ├─┬ chalk@0.4.0
│ │ │   │ ├── ansi-styles@1.0.0
│ │ │   │ ├── has-color@0.1.7
│ │ │   │ └── strip-ansi@0.1.1
│ │ │   └── underscore@1.6.0
│ │ ├── minimist@1.1.1
│ │ └── text-table@0.2.0
│ ├── hat@0.0.3
│ ├── polyline@0.1.0
│ ├─┬ rest@1.3.2
│ │ └── when@3.7.8
│ └── xtend@4.0.1
├── nan@2.8.0
├─┬ node-pre-gyp@0.6.39
│ ├── detect-libc@1.0.3
│ ├─┬ hawk@3.1.3
│ │ ├── boom@2.10.1
│ │ ├── cryptiles@2.0.5
│ │ ├── hoek@2.16.3
│ │ └── sntp@1.0.9
│ ├─┬ mkdirp@0.5.1
│ │ └── minimist@0.0.8
│ ├─┬ nopt@4.0.1
│ │ ├── abbrev@1.1.1
│ │ └─┬ osenv@0.1.4
│ │   ├── os-homedir@1.0.2
│ │   └── os-tmpdir@1.0.2
│ ├─┬ npmlog@4.1.2
│ │ ├─┬ are-we-there-yet@1.1.4
│ │ │ └── delegates@1.0.0
│ │ ├── console-control-strings@1.1.0
│ │ ├─┬ gauge@2.7.4
│ │ │ ├── aproba@1.2.0
│ │ │ ├── has-unicode@2.0.1
│ │ │ ├── object-assign@4.1.1
│ │ │ ├── signal-exit@3.0.2
│ │ │ ├─┬ string-width@1.0.2
│ │ │ │ ├── code-point-at@1.1.0
│ │ │ │ └─┬ is-fullwidth-code-point@1.0.0
│ │ │ │   └── number-is-nan@1.0.1
│ │ │ └── wide-align@1.1.2
│ │ └── set-blocking@2.0.0
│ ├─┬ rc@1.2.2
│ │ ├── deep-extend@0.4.2
│ │ ├── ini@1.3.5
│ │ ├── minimist@1.2.0
│ │ └── strip-json-comments@2.0.1
│ ├─┬ request@2.81.0
│ │ ├── aws-sign2@0.6.0
│ │ ├── aws4@1.6.0
│ │ ├── caseless@0.12.0
│ │ ├─┬ combined-stream@1.0.5
│ │ │ └── delayed-stream@1.0.0
│ │ ├── extend@3.0.1
│ │ ├── forever-agent@0.6.1
│ │ ├─┬ form-data@2.1.4
│ │ │ └── asynckit@0.4.0
│ │ ├─┬ har-validator@4.2.1
│ │ │ ├─┬ ajv@4.11.8
│ │ │ │ ├── co@4.6.0
│ │ │ │ └─┬ json-stable-stringify@1.0.1
│ │ │ │   └── jsonify@0.0.0
│ │ │ └── har-schema@1.0.5
│ │ ├─┬ http-signature@1.1.1
│ │ │ ├── assert-plus@0.2.0
│ │ │ ├─┬ jsprim@1.4.1
│ │ │ │ ├── assert-plus@1.0.0
│ │ │ │ ├── extsprintf@1.3.0
│ │ │ │ ├── json-schema@0.2.3
│ │ │ │ └─┬ verror@1.10.0
│ │ │ │   └── assert-plus@1.0.0
│ │ │ └─┬ sshpk@1.13.1
│ │ │   ├── asn1@0.2.3
│ │ │   ├── assert-plus@1.0.0
│ │ │   ├── bcrypt-pbkdf@1.0.1
│ │ │   ├─┬ dashdash@1.14.1
│ │ │   │ └── assert-plus@1.0.0
│ │ │   ├── ecc-jsbn@0.1.1
│ │ │   ├─┬ getpass@0.1.7
│ │ │   │ └── assert-plus@1.0.0
│ │ │   ├── jsbn@0.1.1
│ │ │   └── tweetnacl@0.14.5
│ │ ├── is-typedarray@1.0.0
│ │ ├── isstream@0.1.2
│ │ ├── json-stringify-safe@5.0.1
│ │ ├─┬ mime-types@2.1.17
│ │ │ └── mime-db@1.30.0
│ │ ├── oauth-sign@0.8.2
│ │ ├── performance-now@0.2.0
│ │ ├── qs@6.4.0
│ │ ├── safe-buffer@5.1.1
│ │ ├── stringstream@0.0.5
│ │ ├─┬ tough-cookie@2.3.3
│ │ │ └── punycode@1.4.1
│ │ ├── tunnel-agent@0.6.0
│ │ └── uuid@3.1.0
│ ├─┬ rimraf@2.6.2
│ │ └─┬ glob@7.1.2
│ │   ├── fs.realpath@1.0.0
│ │   ├── inflight@1.0.6
│ │   ├─┬ minimatch@3.0.4
│ │   │ └─┬ brace-expansion@1.1.8
│ │   │   ├── balanced-match@1.0.0
│ │   │   └── concat-map@0.0.1
│ │   └── path-is-absolute@1.0.1
│ ├── semver@5.4.1
│ ├─┬ tar@2.2.1
│ │ ├── block-stream@0.0.9
│ │ ├─┬ fstream@1.0.11
│ │ │ └── graceful-fs@4.1.11
│ │ └── inherits@2.0.3
│ └─┬ tar-pack@3.4.1
│   ├─┬ debug@2.6.9
│   │ └── ms@2.0.0
│   ├── fstream-ignore@1.0.5
│   ├─┬ once@1.4.0
│   │ └── wrappy@1.0.2
│   ├─┬ readable-stream@2.3.3
│   │ ├── core-util-is@1.0.2
│   │ ├── isarray@1.0.0
│   │ ├── process-nextick-args@1.0.7
│   │ ├── string_decoder@1.0.3
│   │ └── util-deprecate@1.0.2
│   └── uid-number@0.0.6
└─┬ node_or_tools@1.0.5
  └─┬ node-pre-gyp@0.6.36
    ├─┬ mkdirp@0.5.1
    │ └── minimist@0.0.8
    ├─┬ nopt@4.0.1
    │ ├── abbrev@1.1.0
    │ └─┬ osenv@0.1.4
    │   ├── os-homedir@1.0.2
    │   └── os-tmpdir@1.0.2
    ├─┬ npmlog@4.1.2
    │ ├─┬ are-we-there-yet@1.1.4
    │ │ └── delegates@1.0.0
    │ ├── console-control-strings@1.1.0
    │ ├─┬ gauge@2.7.4
    │ │ ├── aproba@1.1.2
    │ │ ├── has-unicode@2.0.1
    │ │ ├── object-assign@4.1.1
    │ │ ├── signal-exit@3.0.2
    │ │ ├─┬ string-width@1.0.2
    │ │ │ ├── code-point-at@1.1.0
    │ │ │ └─┬ is-fullwidth-code-point@1.0.0
    │ │ │   └── number-is-nan@1.0.1
    │ │ ├─┬ strip-ansi@3.0.1
    │ │ │ └── ansi-regex@2.1.1
    │ │ └── wide-align@1.1.2
    │ └── set-blocking@2.0.0
    ├─┬ rc@1.2.1
    │ ├── deep-extend@0.4.2
    │ ├── ini@1.3.4
    │ ├── minimist@1.2.0
    │ └── strip-json-comments@2.0.1
    ├─┬ request@2.81.0
    │ ├── aws-sign2@0.6.0
    │ ├── aws4@1.6.0
    │ ├── caseless@0.12.0
    │ ├─┬ combined-stream@1.0.5
    │ │ └── delayed-stream@1.0.0
    │ ├── extend@3.0.1
    │ ├── forever-agent@0.6.1
    │ ├─┬ form-data@2.1.4
    │ │ └── asynckit@0.4.0
    │ ├─┬ har-validator@4.2.1
    │ │ ├─┬ ajv@4.11.8
    │ │ │ ├── co@4.6.0
    │ │ │ └─┬ json-stable-stringify@1.0.1
    │ │ │   └── jsonify@0.0.0
    │ │ └── har-schema@1.0.5
    │ ├─┬ hawk@3.1.3
    │ │ ├── boom@2.10.1
    │ │ ├── cryptiles@2.0.5
    │ │ ├── hoek@2.16.3
    │ │ └── sntp@1.0.9
    │ ├─┬ http-signature@1.1.1
    │ │ ├── assert-plus@0.2.0
    │ │ ├─┬ jsprim@1.4.1
    │ │ │ ├── assert-plus@1.0.0
    │ │ │ ├── extsprintf@1.3.0
    │ │ │ ├── json-schema@0.2.3
    │ │ │ └─┬ verror@1.10.0
    │ │ │   └── assert-plus@1.0.0
    │ │ └─┬ sshpk@1.13.1
    │ │   ├── asn1@0.2.3
    │ │   ├── assert-plus@1.0.0
    │ │   ├── bcrypt-pbkdf@1.0.1
    │ │   ├─┬ dashdash@1.14.1
    │ │   │ └── assert-plus@1.0.0
    │ │   ├── ecc-jsbn@0.1.1
    │ │   ├─┬ getpass@0.1.7
    │ │   │ └── assert-plus@1.0.0
    │ │   ├── jsbn@0.1.1
    │ │   └── tweetnacl@0.14.5
    │ ├── is-typedarray@1.0.0
    │ ├── isstream@0.1.2
    │ ├── json-stringify-safe@5.0.1
    │ ├─┬ mime-types@2.1.16
    │ │ └── mime-db@1.29.0
    │ ├── oauth-sign@0.8.2
    │ ├── performance-now@0.2.0
    │ ├── qs@6.4.0
    │ ├── safe-buffer@5.1.1
    │ ├── stringstream@0.0.5
    │ ├─┬ tough-cookie@2.3.2
    │ │ └── punycode@1.4.1
    │ ├── tunnel-agent@0.6.0
    │ └── uuid@3.1.0
    ├─┬ rimraf@2.6.1
    │ └─┬ glob@7.1.2
    │   ├── fs.realpath@1.0.0
    │   ├── inflight@1.0.6
    │   ├─┬ minimatch@3.0.4
    │   │ └─┬ brace-expansion@1.1.8
    │   │   ├── balanced-match@1.0.0
    │   │   └── concat-map@0.0.1
    │   └── path-is-absolute@1.0.1
    ├── semver@5.4.1
    ├─┬ tar@2.2.1
    │ ├── block-stream@0.0.9
    │ ├─┬ fstream@1.0.11
    │ │ └── graceful-fs@4.1.11
    │ └── inherits@2.0.3
    └─┬ tar-pack@3.4.0
      ├─┬ debug@2.6.8
      │ └── ms@2.0.0
      ├── fstream-ignore@1.0.5
      ├─┬ once@1.4.0
      │ └── wrappy@1.0.2
      ├─┬ readable-stream@2.3.3
      │ ├── core-util-is@1.0.2
      │ ├── isarray@1.0.0
      │ ├── process-nextick-args@1.0.7
      │ ├── string_decoder@1.0.3
      │ └── util-deprecate@1.0.2
      └── uid-number@0.0.6

So, do I miss something? please advice..

daniel-j-h commented 6 years ago

As for installed dependencies versions as below: ( mapbox@0.12.0 )

Not sure why you have 0.12.0 installed, the example installs 1.0.0 per

https://github.com/mapbox/node-or-tools/blob/master/example/package.json#L11

which comes with the getMatrix function per the API

https://github.com/mapbox/mapbox-sdk-js/blob/master/API.md#getmatrix