错误:找不到模块“正常” AWS Lambda Nforce Salesforce

时间:2019-11-18 09:06:34

标签: node.js amazon-web-services aws-lambda salesforce

我的Node.js代码在本地工作正常,但是当我在AWS lambda函数上上传时,出现以下错误:

  

错误:找不到模块“属性”

**I have tried 
 exports.handler = function (event,context) 
 exports.handler = function (event,context,callback)  
 exports.handler = function (event)** 

无法添加文件夹结构的照片。请点击以下链接获取文件夹结构

Click for the folder structure

Index.js

var CLIENT_ID = '**************************';
var CLIENT_SECRET = '*******************************';
var USERNAME = '**************';
var PASSWORD = '*********';
var CALLBACK_URL = 'http://localhost:3000/oauth/_callback';
var SECURITY_TOKEN = '***************************************';

var nforce = require('nforce');
exports.handler = function (event, context,callback) {

    var newCase = nforce.createSObject('Case');
    newCase.set('Device_Id__c', event.serialNumber);
    newCase.set('Button_Press_Type__c', event.clickType);
    newCase.set('Button_Notes__c', ' AWS Dash button Id: 34254555 Click Type: clickType');

    if(event.clickType  == 'Long'){
        newCase.set('Priority', 'High');
        newCase.set('Subject', 'High |'+  event.clickType +' | ' + event.serialNumber);
    }
    if(event.clickType  == 'Double')    {
        newCase.set('Priority', 'Medium');
        newCase.set('Subject', 'Medium |'+  event.clickType +' | ' + event.serialNumber);
    }
    if(event.clickType  == 'Single')    {
        newCase.set('Priority', 'Medium');
        newCase.set('Subject', 'Medium |'+  event.clickType +' | ' + event.serialNumber);
    }

    var org = nforce.createConnection({
        clientId: CLIENT_ID,
        clientSecret: CLIENT_SECRET,
        redirectUri: CALLBACK_URL,
        environment: 'production', 
        mode: 'single'
      });

      org.authenticate({ username: USERNAME, password: PASSWORD, }, function(err, resp){
         // store the oauth object for this user
         if(!err){ 
            //var oauth = resp;
            console.log('Cached Token: ' + org.message);
            org.insert({ sobject: newCase }, function(err, resp){
                if(!err) console.log('It worked! ==> ' + resp);
                else console.log('Error ===> ' + err);
              }); 

            } else {
                console.log('Error: ' + JSON.stringify(resp));
                console.log('Error: ' + JSON.stringify(err));
                console.log('Error: ' + err.message);
            }
    });
}; 

1 个答案:

答案 0 :(得分:0)

将nforce库重新安装在一个文件夹中,并将index.js放置在该文件夹中。压缩并上传到AWS并工作。看起来与nforce安装有关。