我最近开始在AWS上开发Lambda函数。尝试导入JavaScript文件时,出现以下错误,并且我还使用了DynamoDb
module initialization error: TypeError
at Object.<anonymous> (/var/task/index.js:14:16)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
这是我与节点模块和package.json压缩在一起的代码
const alexaSDK = require('alexa-sdk');
const awsSDK = require('aws-sdk');
const promisify = require('es6-promisify');
awsSDK.config.update({
region: "us-west"
});
//const appId = 'REPLACE WITH YOUR SKILL APPLICATION ID';
const recipesTable = 'Recipes';
const docClient = new awsSDK.DynamoDB.DocumentClient();
// convert callback style functions to promises
const dbScan = promisify(docClient.scan, docClient);
const dbGet = promisify(docClient.get, docClient);
const dbPut = promisify(docClient.put, docClient);
const dbDelete = promisify(docClient.delete, docClient);
我已经安装了所有必需的东西。任何人都可以帮助解决此错误。