Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using aws-sdk with angular2

I'm trying to get my Angular2 app to allow me to read and write to an s3 bucket on my AWS account.

In AngularJS (and most other things) we used the aws-sdk so I'm assuming that the same thing will be able to be done for Angular2 also.

The problem I'm having though is getting the aws-sdk 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.

like image 918
Nicholas Tsaoucis Avatar asked May 05 '16 01:05

Nicholas Tsaoucis


People also ask

Can we use AWS SDK in angular?

aws-sdk is not compatible with Angular 12 #3824.

What can you do with AWS SDK?

The AWS SDK for JavaScript simplifies use of AWS Services by providing a set of libraries that are consistent and familiar for JavaScript developers. It provides support for API lifecycle consideration such as credential management, retries, data marshaling, serialization, and deserialization.


1 Answers

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

Update TypeScript and aws-sdk to latest. In your tsconfig make sure you have moduleResolution: node. Now you can simply do:

import * as AWS from 'aws-sdk';
like image 170
basarat Avatar answered Oct 05 '22 08:10

basarat