node.js - 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)。
解决方案
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.
推荐阅读
- amazon-web-services - K8s 节点路由
- google-cloud-dataflow - 避免连接字符串在数据流作业模板中出现
- android - 以编程方式使用 Amazon pinpiont 发送推送通知
- ckeditor - 在 CKEditor 中选择可编辑节点内的文本
- sql-server - 如何在mac上使用docker连接sql server?
- javascript - 以下代码是否容易受到基于 dom 的 xss 的攻击?
- android - 房间查询返回列子集时出错
- php - Woocommerce 从购物车商品计数中删除 free_gift
- c - 从传递给符合 MISRA 规则 17.4 的函数的 void 指针参数访问所有数组元素
- .htaccess - 如何将目录重写为查询字符串