Search code examples
node.jsangularnode-modulesamadeus

Validator.js Module not found - Can't resolve http in client


I've got some trouble implementing the amadeus-node package into an angular 10 project. As soon as I implement the following line

const Amadeus = require('amadeus');

I receive this error

ERROR in ./node_modules/amadeus/lib/amadeus/client/validator.js Module not found: Error: Can't resolve 'http' in '\node_modules\amadeus\lib\amadeus\client'

But the validator.js exists. Any tips to solve the problem? By the way... some type definitions would be great ;)

Edit

I think I missunderstood the error message. But I'm still not sure what's wrong. I think the error occurs in validator.js and he's missing a module named 'http' in the path '\node_modules\amadeus\lib\amadeus\client'. But this makes no sense. He should use the http module of node.js. I'm using the latest LTS version of node.js (12.18.3).


Solution

  • Ok it seems I was using the package wrong. I opened an issue at the developers github page:

    https://github.com/amadeus4dev/amadeus-node/issues/85

    this was the response:

    Hey! Thanks for reporting this issue. The SDK is not designed to work on client-side frameworks like Angular (you can see that Angular cannot resolve the http-node dependency from amadeus-sdk) but on nodejs applications.

    By the way, we have never consumed the SDK within a Typescript application. I believe it's not going to work out-of-the-box as it needs to provide a type declaration file.