首页 > 解决方案 > Validator.js 模块未找到 - 无法在客户端解析 http

问题描述

我在将 amadeus-node 包实施到 angular 10 项目中时遇到了一些麻烦。一旦我实施以下行

const Amadeus = require('amadeus');

我收到此错误

./node_modules/amadeus/lib/amadeus/client/validator.js 中的错误找不到模块:错误:无法解析“\node_modules\amadeus\lib\amadeus\client”中的“http”

但是 validator.js 存在。有什么技巧可以解决这个问题吗?顺便说一句......一些类型定义会很棒;)

编辑

我想我误解了错误信息。但我仍然不确定出了什么问题。我认为该错误发生在 validator.js 中,并且他在路径“\node_modules\amadeus\lib\amadeus\client”中缺少一个名为“http”的模块。但这没有任何意义。他应该使用node.js的http模块。我正在使用最新的 LTS 版本的 node.js (12.18.3)。

标签: node.jsangularnode-modulesamadeus

解决方案


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.


推荐阅读