Monday, 17 April 2017

TypeError: AWS.DynamoDB.DocumentClient is not a constructor

I try to use Amazons DocumentClient for AWS.dynamodb from the aws-sdk. I also use the Standard node.js VM from Amazon: "64bit Amazon Linux 2016.09 v4.0.1 running Node.js".

On my local machine everything is working fine, but I get the following error message live:

TypeError: AWS.DynamoDB.DocumentClient is not a constructor

And this is the line causing the error:

var docClient = new AWS.DynamoDB.DocumentClient();

I also tried different versions which are used by various tutorials which also fail:

var docClient = new AWS.DynamoDB.DocumentClient({region: "eu-central-1"});

var docClient = new AWS.DynamoDB.DocumentClient({apiVersion: '2012-08-10'});

I tried to follow this guide very precisely: https://aws.amazon.com/de/blogs/developer/announcing-the-amazon-dynamodb-document-client-in-the-aws-sdk-for-javascript/

On my local machine it works without a problem. I can connect to the live server or the local dev-server without errors.

AWS.dynamodb without the DocumentClient was also working on the live server, so I guess one option would be to drop DocumentClient alltogether.

I have a package.json which uses the latest aws-sdk:

{
  "name": "",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "aws-sdk": "latest",
[...]

My best guess is, that something is wrong with the node packages. How do I check my assumption and if right, change something about it?



via mo1

No comments:

Post a Comment