Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure aws-sdk in Angular 7

When I do

npm install  aws-sdk 

in Angular 7, I get an error

Error TS2580: Cannot find name 'Buffer'.

Do you need to install type definitions for node? Try npm i @types/node

and even though I do run install npm i @types/node, I am still getting the same error:

even though i install  npm i @types/node i am getting same error

like image 380
Sudheer Saladi Avatar asked Jan 04 '19 08:01

Sudheer Saladi


People also ask

What is AWS SDK for JavaScript?

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.


2 Answers

To resolve this issue, you can try to add in your tsconfig.app.json the following line:

"types": ["node"]

Angular is complaining because some node environment types are needed.

like image 163
Johan Rin Avatar answered Sep 21 '22 00:09

Johan Rin


Please modify your files as follows:

// aws-sdk requires global to exist
(window as any).global = window;

to /src/polyfills.ts and

"types": ["node"]

to compilerOptions block in /src/tsconfig.app.json

credit to: afaneh262

like image 27
p4309027 Avatar answered Sep 24 '22 00:09

p4309027