Validator.js 未找到模块 - 无法在客户端解析 http
Validator.js Module not found - Can't resolve http in client
我在将 amadeus-node 包实施到 angular 10 项目时遇到了一些问题。
只要我执行以下行
const Amadeus = require('amadeus');
我收到这个错误
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'
但是 validator.js 存在。有什么解决问题的技巧吗?
顺便说一句......一些类型定义会很棒;)
编辑
我想我误解了错误信息。但我仍然不确定出了什么问题。我认为错误发生在 validator.js 中,并且他在路径“\node_modules\amadeus\lib\amadeus\client”中缺少名为 'http' 的模块。但这没有意义。他应该使用node.js的http模块。我使用的是 node.js (12.18.3) 的最新 LTS 版本。
好吧,看来我用错了包。我在开发人员 github 页面上打开了一个问题:
https://github.com/amadeus4dev/amadeus-node/issues/85
这是回应:
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.
我在将 amadeus-node 包实施到 angular 10 项目时遇到了一些问题。 只要我执行以下行
const Amadeus = require('amadeus');
我收到这个错误
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'
但是 validator.js 存在。有什么解决问题的技巧吗? 顺便说一句......一些类型定义会很棒;)
编辑
我想我误解了错误信息。但我仍然不确定出了什么问题。我认为错误发生在 validator.js 中,并且他在路径“\node_modules\amadeus\lib\amadeus\client”中缺少名为 'http' 的模块。但这没有意义。他应该使用node.js的http模块。我使用的是 node.js (12.18.3) 的最新 LTS 版本。
好吧,看来我用错了包。我在开发人员 github 页面上打开了一个问题:
https://github.com/amadeus4dev/amadeus-node/issues/85
这是回应:
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.