TypeError: must call as: npm.load(callback) when running NPX command locally from Google Maps API documentation

Viewed 343

Trying to run the following Google Maps API example locally with this command:

npx @googlemaps/js-samples init directions-waypoints googlemapssample

But everytime I try to run the npx command locally, it fails after a few seconds and I get the following error:

TypeError: must call as: npm.load(callback)
    at Object.load (C:\tmp\nodejs\npm-cache\_npx\33944\node_modules\@googlemaps\js-samples\node_modules\npm\lib\npm.js:123:13)
    at Object.main [as handler] (C:\tmp\nodejs\npm-cache\_npx\33944\node_modules\@googlemaps\js-samples\cli\index.js:84:9)

I have npm version npm version 6.14.5 and node version 14.4.0. Don't really understand why I am getting this error.

1 Answers

Apparently they're using a deprecated call to the npm.load(options, callback) method. NPM seems to expect only one callback argument (without an options argument). My guess is that few people try to run it this way. I don't know if this cryptic Issue was opened to fix this problem: https://github.com/googlemaps/js-samples/issues/335

Related