title: How to use Cheerio with Angular?
body: <p>I am getting errors on Google Dev Tools's console when I load my Angular website and make a call to a Cheerio method <code>load('&lt;h2 class="title"&gt;Hello world&lt;/h2&gt;');</code> as shown on the Github page.</p>
  
  <p>This is a brand new application, so all I've done is: 
  <code>sudo ng new myProject</code>,
  <code>sudo chmod -R 777 myProject/</code>,
  <code>sudo npm install cheerio --save</code>,
  <code>sudo npm install @types/cheerio --save</code>.
  Also, because I have gotten errors in the TypeScript compilation in the past, I also ran: <code>sudo npm install stream --save</code></p>
  
  <p>Atop my <code>app.component.ts</code> file I call <code>import * as cheerio from 'cheerio';</code> and lastly inside the component:</p>
  
  <pre><code>ngOnInit() {
    cheerio.load('&lt;h2 class="title"&gt;Hello world&lt;/h2&gt;');
  }
  </code></pre>
  
  <p>Now, when I run <code>ng serve</code>, the exact error message I get is:</p>
  
  <pre><code>inherits_browser.js:5 Uncaught TypeError: Cannot read property 'prototype' of undefined
      at inherits (inherits_browser.js:5)
      at Object../node_modules/cheerio/node_modules/parse5/lib/parser/parser_stream.js (parser_stream.js:27)
      at __webpack_require__ (bootstrap:78)
      at Object../node_modules/cheerio/node_modules/parse5/lib/index.js (index.js:41)
      at __webpack_require__ (bootstrap:78)
      at Object../node_modules/cheerio/lib/parse.js (parse.js:5)
      at __webpack_require__ (bootstrap:78)
      at Object../node_modules/cheerio/lib/cheerio.js (cheerio.js:5)
      at __webpack_require__ (bootstrap:78)
      at Object../node_modules/cheerio/index.js (index.js:5)
  inherits @ inherits_browser.js:5
  ./node_modules/cheerio/node_modules/parse5/lib/parser/parser_stream.js @ parser_stream.js:27
  __webpack_require__ @ bootstrap:78
  ./node_modules/cheerio/node_modules/parse5/lib/index.js @ index.js:41
  __webpack_require__ @ bootstrap:78
  ./node_modules/cheerio/lib/parse.js @ parse.js:5
  __webpack_require__ @ bootstrap:78
  ./node_modules/cheerio/lib/cheerio.js @ cheerio.js:5
  __webpack_require__ @ bootstrap:78
  ./node_modules/cheerio/index.js @ index.js:5
  __webpack_require__ @ bootstrap:78
  ./src/app/app.component.ts @ main.js:94
  __webpack_require__ @ bootstrap:78
  ./src/app/app.module.ts @ app.component.ts:10
  __webpack_require__ @ bootstrap:78
  ./src/main.ts @ main.ts:1
  __webpack_require__ @ bootstrap:78
  0 @ main.ts:12
  __webpack_require__ @ bootstrap:78
  checkDeferredModules @ bootstrap:45
  webpackJsonpCallback @ bootstrap:32
  (anonymous) @ main.js:1
  </code></pre>
  
  <p>Additionally, if you're going to recommend to instead put <code>import { load } from 'cheerio';</code> atop the file, I have tried this as well, and the same error appears.</p>
  
  <p>These are the versions of my tools (they're all the latest or very close).
  Angular CLI: 7.3.6
  Node: 11.12.0
  OS: darwin x64
  Angular: 7.2.11</p>
  
  <p>Edit: I have tried the solution in <a href="https://stackoverflow.com/questions/52580570/adding-cheerio-js-to-an-angular-6-project">Adding Cheerio.js to an Angular 6 project?</a>, and it did not solve the problem, in fact it added another error in the console: </p>
  
  <pre><code>cheerio.js:5 Uncaught ReferenceError: require is not defined
      at cheerio.js:5
  </code></pre>