我目前正在使用nativescript 6.0.2来构建一个跨平台的应用程序,我需要能够使用aws-cognito身份验证来上传文件到s3。
我曾尝试使用npm install安装javascript aws-sdk,但在构建之前遇到了这些错误。
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时,它会使用端点、访问密钥和密钥。
发布于 2019-11-01 10:48:05
我遇到了这个问题,实际上nativescript-nodeify与nativescript的最新版本不一致(我使用的是6.0.2)。
我试图在我的环境中逐个修复它们,并找到了以下解决方案。
在webpack.config.js中,在"node“块中添加以下4行代码。
node: {
"child_process": "empty",
"dgram": "empty",
"net": "empty",
"crypto": true,
},后来,当我要为S3/存储API使用aws-amplify时,我被困住了,但这应该会让您继续前进。
https://stackoverflow.com/questions/57528120
复制相似问题