3

I'm using the AWS Node.js API (aws-sdk) version 1.0.0 on Node version 0.11.2. I get an error simply constructing the API object:

var AWS = require('aws-sdk');
AWS.config.update({region: 'eu-west-1'});
var s3 = AWS.S3();

The error is:

/.../node_modules/aws-sdk/lib/service.js:25
var ServiceClass = this.loadServiceClass(config || {});
                        ^
TypeError: Object #<Object> has no method 'loadServiceClass'
    at Object.Service (/.../node_modules/aws-sdk/lib/service.js:25:29)
    at Object.features.constructor [as S3] (/.../node_modules/aws-sdk/lib/util.js:405:24)
    at ReadStream.<anonymous> (/.../server.js:92:22)
    at ReadStream.EventEmitter.emit (events.js:97:17)
    at fs.js:1492:10
    at Object.oncomplete (fs.js:94:15)

I get the same error with Node 0.8.23, 0.9.12 and 0.10.5 too.

I can't find any reference to this error anywhere, so it obviously doesn't happen to anyone else! What am I doing wrong?

1 Answer 1

5

You have to create a new object for s3 via new:

var AWS = require('aws-sdk');
AWS.config.update({region: 'eu-west-1'});
var s3 = new AWS.S3();

which should work without any problem.

Sign up to request clarification or add additional context in comments.

1 Comment

It's OK. I don't feel too stupid about having stared at the docs and examples for about 2 hours and not spotting this even once! :-/ Thanks you so much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.