未捕获的错误:"aws-sdk"的脚本错误 [英] Uncaught Error: Script error for "aws-sdk"

查看:153
本文介绍了未捕获的错误:"aws-sdk"的脚本错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试将AWS开发工具包用于节点,但出现此错误未捕获的错误:"aws-sdk"的脚本错误 这是我的代码.我尝试使用require('aws-sdk'),但控制台错误比说使用require([],()=> {}) 我从npm下载了require和aws-sdk

Trying to use the AWS SDK for node but I get this error Uncaught Error: Script error for "aws-sdk" Heres my code. I tried using require('aws-sdk'), but the console error than said to use require([],()=>{}) I downloaded both require and aws-sdk from npm

require(['aws-sdk'], (AWS) => {
    let email = document.getElementById('footerEmail');
    let emailSubmit = document.getElementById('footerButton');
    AWS.config.update({ region: 'us-east-1' });


    let sns = new AWS.SNS();

    let params = {
        Protocol: 'email', /* required */
        TopicArn: 'arn:aws:sns:us-east-1:274999247491:HouseRoots', /* required */
        Endpoint: email.value,
        ReturnSubscriptionArn: false
    };
    console.log('h');
    emailSubmit.addEventListener('click', () => {
        console.log('h');
        sns.subscribe(params, function (err, data) {
            if (err) {
                email.value = "error occured";
                console.log(err);
            }
            else {
                email.value = "confirmation sent";
            }
        });
        console.log('h');
    });
});

推荐答案

我为您准备了一个基本的示例应用程序,

I prepare you a basic sample app, press here.

要运行:

  • npm安装
  • 节点app.js
  • 打开浏览器localhost:3000/

您必须预先配置:

  • aws_credentials文件

  • aws_credentials file

您必须更改app.js中的区域( AWS.config.update({region:'REGION'}); )

you must change region in app.js (AWS.config.update({region: 'REGION'});)

用户必须访问SNS

流量:

这篇关于未捕获的错误:"aws-sdk"的脚本错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆