Sudheer Saladi
Sudheer Saladi

Reputation: 143

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

Upvotes: 7

Views: 3399

Answers (3)

Hammad Ali
Hammad Ali

Reputation: 111

You need to make a change in tsconfig.app.json file first inside compilerOptions as follows:

"types": ["node"]

After that, add a code in polyfills.js file. Otherwise you will get an error later (ReferenceError: global is not defined). Here is the code:

(window as any).global = window;

Upvotes: 0

p4309027
p4309027

Reputation: 311

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

Upvotes: 4

Johan Rin
Johan Rin

Reputation: 1950

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.

Upvotes: 11

Related Questions