首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在nativescript 6.0中使用aws-sdk?

如何在nativescript 6.0中使用aws-sdk?
EN

Stack Overflow用户
提问于 2019-08-17 00:27:45
回答 1查看 487关注 0票数 3

我目前正在使用nativescript 6.0.2来构建一个跨平台的应用程序,我需要能够使用aws-cognito身份验证来上传文件到s3。

我曾尝试使用npm install安装javascript aws-sdk,但在构建之前遇到了这些错误。

代码语言:javascript
复制
ERROR in ../node_modules/aws-sdk/lib/credentials/process_credentials.js
Module not found: Error: Can't resolve 'child_process' in '/Users/nabhanmaswood/Desktop/Computer/Quadrant2/wowza-nativescript-plugin/demo-angular/node_modules/aws-sdk/lib/credentials'
 @ ../node_modules/aws-sdk/lib/credentials/process_credentials.js 2:11-35
 @ ../node_modules/aws-sdk/lib/node_loader.js
 @ ../node_modules/aws-sdk/lib/aws.js
 @ ./app/home/home.component.ts
 @ ./app/home/home.module.ts
 @ ../$$_lazy_route_resource lazy namespace object
 @ ../node_modules/@angular/core/fesm5/core.js
 @ ./app/app.module.ts
 @ ./main.ts

ERROR in ../node_modules/aws-sdk/lib/publisher/index.js
Module not found: Error: Can't resolve 'dgram' in '/Users/nabhanmaswood/Desktop/Computer/Quadrant2/wowza-nativescript-plugin/demo-angular/node_modules/aws-sdk/lib/publisher'
 @ ../node_modules/aws-sdk/lib/publisher/index.js 2:12-28
 @ ../node_modules/aws-sdk/lib/node_loader.js
 @ ../node_modules/aws-sdk/lib/aws.js
 @ ./app/home/home.component.ts
 @ ./app/home/home.module.ts
 @ ../$$_lazy_route_resource lazy namespace object
 @ ../node_modules/@angular/core/fesm5/core.js
 @ ./app/app.module.ts
 @ ./main.ts

ERROR in ../node_modules/xml2js/lib/parser.js
Module not found: Error: Can't resolve 'timers' in '/Users/nabhanmaswood/Desktop/Computer/Quadrant2/wowza-nativescript-plugin/demo-angular/node_modules/xml2js/lib'
 @ ../node_modules/xml2js/lib/parser.js 17:17-34
 @ ../node_modules/xml2js/lib/xml2js.js
 @ ../node_modules/aws-sdk/lib/xml/node_parser.js
 @ ../node_modules/aws-sdk/lib/node_loader.js
 @ ../node_modules/aws-sdk/lib/aws.js
 @ ./app/home/home.component.ts
 @ ./app/home/home.module.ts
 @ ../$$_lazy_route_resource lazy namespace object
 @ ../node_modules/@angular/core/fesm5/core.js
 @ ./app/app.module.ts
 @ ./main.ts

我知道要将aws-sdk与nativescript一起使用,你需要使用插件nativescript-nodeify,但问题是这个插件目前与nativescript 6.0.2不兼容。

我该如何修复这个错误,或者有没有其他方法可以使用aws-sdk来上传到s3?

我知道nativescript-aws-sdk插件,但这只适用于s3,当我也需要使用amazon cognito时,它会使用端点、访问密钥和密钥。

EN

回答 1

Stack Overflow用户

发布于 2019-11-01 10:48:05

我遇到了这个问题,实际上nativescript-nodeify与nativescript的最新版本不一致(我使用的是6.0.2)。

我试图在我的环境中逐个修复它们,并找到了以下解决方案。

在webpack.config.js中,在"node“块中添加以下4行代码。

代码语言:javascript
复制
        node: {
            "child_process": "empty",
            "dgram": "empty",
            "net": "empty",
            "crypto": true,
        },

后来,当我要为S3/存储API使用aws-amplify时,我被困住了,但这应该会让您继续前进。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57528120

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档