title: ERROR ReferenceError: "Buffer is not defined" while `ng build`
body: <p>I'm trying to use Buffer in my angular component ts for encoding Authorization string.</p>
  
  <p>It is not compiling with <code>ng build</code>. I tried <code>npm i @types/node</code> and added "node" to types field in tsconfig.json. But error is still there.</p>
  
  <p><strong><em>Following is error detail:</em></strong></p>
  
  <pre><code>ERROR in src/app/register/register.component.ts(40,29): error TS2591: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
  </code></pre>
  
  <p><strong><em>Here is code of register.component.ts</em></strong></p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { HttpClient, HttpHeaders } from '@angular/common/http';
  import { User, PricingPlan } from 'api';
  import * as EmailValidator from 'email-validator';
  
  @Component({
    selector: 'app-register',
    templateUrl: './register.component.html',
    styleUrls: ['./register.component.scss']
  })
  export class RegisterComponent implements OnInit {
    model = new User();
    passwordRepeat = '';
    pricingPlans: PricingPlan[];
    userExist = false;
  
    serverUrl = 'http://127.0.0.1:3000/';
    registerSuccess = false;
    registerFailed = false;
  
    constructor(private http: HttpClient) {}
  
    ngOnInit() {
      this.http
        .get(`${this.serverUrl}pricingplans`)
        .subscribe((pricingplans: PricingPlan[]) =&gt; {
          this.pricingPlans = pricingplans;
        });
    }
  
    validateEmail(em) {
      return EmailValidator.validate(em);
    }
  
    validatePasswords() {
      return this.passwordRepeat === this.model.password;
    }
  
    save() {
      const auth = 'Basic ' + Buffer.from(this.model.email).toString('base64');
  
      this.http.get(`${this.serverUrl}user`, {
        headers: {
          Authorization: auth
        }
      }).subscribe((responce: User) =&gt; {
        this.userExist = (responce.email === this.model.email);
      });
  
      if (this.userExist) {
        return;
      }
    }
  }
  </code></pre>
  
  <p><strong><em>Following is my tsconfig.json</em></strong></p>
  
  <pre><code>{
    "compileOnSave": false,
    "compilerOptions": {
      "baseUrl": "./",
      "outDir": "./dist/out-tsc",
      "sourceMap": true,
      "declaration": false,
      "downlevelIteration": true,
      "experimentalDecorators": true,
      "module": "esnext",
      "moduleResolution": "node",
      "importHelpers": true,
      "target": "es2015",
      "typeRoots": [
        "node_modules/@types"
      ],
      "types": [
        "node"
      ],
      "lib": [
        "es2018",
        "dom"
      ]
    },
    "angularCompilerOptions": {
      "fullTemplateTypeCheck": true,
      "strictInjectionParameters": true
    }
  }
  </code></pre>