I'm trying to update a Lambda function using this command:
aws lambda update-function-code --function-name my-function --zip-file fileb://package.zip
However, this results in a Windows Script Host error:
/path/to/aws.js
Line: 1
Char: 1
Error: Syntax error
Code: 800A03EA
Source: Microsoft JScript compilation error
The contents of aws.js:
const AWS = require('aws-sdk');
exports.dynamodb = new AWS.DynamoDB.DocumentClient({
api_version: '2012-08-10',
region: 'us-east-1'
});
exports.iot = new AWS.IotData({
apiVersion: '2015-05-28',
endpoint: 'redacted.iot.us-east-1.amazonaws.com',
region: 'us-east-1'
});
exports.AWS = AWS;
If I run this file using node (node /path/to/aws.js), I get no output. If I double-click on the file, I get the same error.
It seems like aws lambda update-function-code is checking the file for syntax errors, but not using node.
I don't see any node syntax errors. How can I solve this?
I'm using NVM for Windows (I'm on Windows 10), and node v10.23.0 is active. I have successfully updated this function before, and I made no changes to aws.js.