How to configure aws-sdk in Angular 7

Viewed 3037

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

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.

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

Related