Nicholas Tsaoucis Nicholas Tsaoucis - 1 month ago 166x
TypeScript Question

Using aws-sdk with angular2

I'm trying to get my

app to allow me to read and write to an s3 bucket on my AWS account.

(and most other things) we used the
so I'm assuming that the same thing will be able to be done for

The problem I'm having though is getting the
to import correctly into my project.

I've installed it via
npm install aws-sdk

I've tried to import it using

import * as AWS from 'aws-sdk/dist/aws-sdk',
import * as AWS from 'aws-sdk',
import AWS from 'aws-sdk'
import AWS from 'aws-sdk/dist/aws-sdk'

but it keeps telling me that the module doesn't exist.

My project is based off the angular2-seed.

I also tried to install the typings file from DefinitleyTyped using
typings install aws-sdk
but that failed also.

I'm not sure about if I need to add anything else in order for it to work or not.

Also, I'm using typescript

Thanks for your time and assistance.


I found that if I added

{ src: 'aws-sdk/dist/aws-sdk', inject: 'libs' } 

to the additional_deps in the project.config.ts (if your using angular2-seed) or just add

<script src="/node_modules/aws-sdk/dist/aws-sdk.js"></script>

to your index.html Then I could add

declare const AWS: any;

To any of the .ts files I needed, I have access to the AWS object. Not sure if this is a good solution however.