title: Using JSDOM with Angular
body: <p>I have an Angular 6 project and I want to parse html as browser do (with scripts etc.) so i decided to use JSDOM.
  The thing is that I get a lot of errors when running <code>ng serve</code>.
  Probably I have not installed some packages but I have already tried a lot of combinations and nothing worked.</p>
  
  <p>This is my "invoke" of jsdom:</p>
  
  <pre><code>import { JSDOM } from 'jsdom';
  
  const dom = new JSDOM(`&lt;!DOCTYPE html&gt;&lt;p&gt;Hello world&lt;/p&gt;`);
  </code></pre>
  
  <p>Here is my package.json:</p>
  
  <pre><code>"dependencies": {
      "@angular/animations": "^6.0.5",
      "@angular/common": "^6.0.5",
      "@angular/compiler": "^6.0.5",
      "@angular/core": "^6.0.5",
      "@angular/forms": "^6.0.5",
      "@angular/http": "^6.0.5",
      "@angular/platform-browser": "^6.0.5",
      "@angular/platform-browser-dynamic": "^6.0.5",
      "@angular/platform-server": "^6.0.5",
      "@angular/router": "^6.0.5",
      "angularfire2": "^5.0.0-rc.10",
      "core-js": "^2.5.7",
      "firebase": "^5.0.4",
      "ngx-slick": "^0.1.3",
      "rxjs": "^6.2.1",
      "rxjs-compat": "^6.2.1",
      "zone.js": "^0.8.26"
    },
    "devDependencies": {
      "@angular-devkit/build-angular": "^0.6.8",
      "@angular/cli": "^6.0.8",
      "@angular/compiler-cli": "^6.0.5",
      "@angular/language-service": "^6.0.5",
      "@types/core-js": "^2.5.0",
      "@types/jasmine": "^2.8.8",
      "@types/jasminewd2": "~2.0.2",
      "@types/jsdom": "11.0.6",
      "@types/node": "^10.3.4",
      "codelyzer": "^4.3.0",
      "jasmine-core": "^3.1.0",
      "jasmine-spec-reporter": "~4.2.1",
      "jsdom": "^11.11.0",
      "karma": "^2.0.3",
      "karma-chrome-launcher": "~2.2.0",
      "karma-coverage-istanbul-reporter": "1.2.1",
      "karma-jasmine": "^1.1.2",
      "karma-jasmine-html-reporter": "0.2.2",
      "protractor": "^5.3.2",
      "ts-node": "^6.1.1",
      "tslint": "^5.10.0",
      "typescript": "^2.9.2"
    }
  </code></pre>
  
  <p>and here are errors:</p>
  
  <pre><code>WARNING in ./node_modules/jsdom/lib/jsdom/utils.js
  186:21-40 Critical dependency: the request of a dependency is an expression
  
  WARNING in ./node_modules/parse5/lib/index.js
  55:23-49 Critical dependency: the request of a dependency is an expression
  
  WARNING in ./node_modules/sax/lib/sax.js
  Module not found: Error: Can't resolve 'stream' in 'E:\moj-git\MovieApp\node_modules\sax\lib'
  
  ERROR in ./node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js
  Module not found: Error: Can't resolve 'child_process' in 'E:\moj-git\MovieApp\node_modules\jsdom\lib\jsdom\living'
  ERROR in ./node_modules/aws4/aws4.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\aws4'
  ERROR in ./node_modules/ecc-jsbn/index.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\ecc-jsbn'
  ERROR in ./node_modules/oauth-sign/index.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\oauth-sign'
  ERROR in ./node_modules/request/lib/helpers.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\request\lib'
  ERROR in ./node_modules/request/lib/hawk.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\request\lib'
  ERROR in ./node_modules/request/lib/oauth.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\request\lib'
  ERROR in ./node_modules/request/node_modules/aws-sign2/index.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\request\node_modules\aws-sign2'
  ERROR in ./node_modules/request/node_modules/http-signature/lib/verify.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\request\node_modules\http-signature\lib'
  ERROR in ./node_modules/request/node_modules/http-signature/lib/signer.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\request\node_modules\http-signature\lib'
  ERROR in ./node_modules/sshpk/lib/utils.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\sshpk\lib'
  ERROR in ./node_modules/sshpk/lib/private-key.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\sshpk\lib'
  ERROR in ./node_modules/sshpk/lib/identity.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\sshpk\lib'
  ERROR in ./node_modules/sshpk/lib/fingerprint.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\sshpk\lib'
  ERROR in ./node_modules/sshpk/lib/signature.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\sshpk\lib'
  ERROR in ./node_modules/sshpk/lib/dhe.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\sshpk\lib'
  ERROR in ./node_modules/sshpk/lib/key.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\sshpk\lib'
  ERROR in ./node_modules/sshpk/lib/certificate.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\sshpk\lib'
  ERROR in ./node_modules/sshpk/lib/formats/openssh-cert.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\sshpk\lib\formats'
  ERROR in ./node_modules/sshpk/lib/formats/pem.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\sshpk\lib\formats'
  ERROR in ./node_modules/sshpk/lib/formats/ssh-private.js
  Module not found: Error: Can't resolve 'crypto' in 'E:\moj-git\MovieApp\node_modules\sshpk\lib\formats'
  ERROR in ./node_modules/cssstyle/lib/CSSStyleDeclaration.js
  Module not found: Error: Can't resolve 'fs' in 'E:\moj-git\MovieApp\node_modules\cssstyle\lib'
  ERROR in ./node_modules/jsdom/lib/jsdom/browser/resource-loader.js
  Module not found: Error: Can't resolve 'fs' in 'E:\moj-git\MovieApp\node_modules\jsdom\lib\jsdom\browser'
  ERROR in ./node_modules/jsdom/lib/jsdom/living/xhr-utils.js
  Module not found: Error: Can't resolve 'fs' in 'E:\moj-git\MovieApp\node_modules\jsdom\lib\jsdom\living'
  ERROR in ./node_modules/pn/fs.js
  Module not found: Error: Can't resolve 'fs' in 'E:\moj-git\MovieApp\node_modules\pn'
  ERROR in ./node_modules/request/lib/har.js
  Module not found: Error: Can't resolve 'fs' in 'E:\moj-git\MovieApp\node_modules\request\lib'
  ERROR in ./node_modules/forever-agent/index.js
  Module not found: Error: Can't resolve 'http' in 'E:\moj-git\MovieApp\node_modules\forever-agent'
  ERROR in ./node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js
  Module not found: Error: Can't resolve 'http' in 'E:\moj-git\MovieApp\node_modules\jsdom\lib\jsdom\living'
  ERROR in ./node_modules/request/request.js
  Module not found: Error: Can't resolve 'http' in 'E:\moj-git\MovieApp\node_modules\request'
  ERROR in ./node_modules/request/node_modules/http-signature/lib/signer.js
  Module not found: Error: Can't resolve 'http' in 'E:\moj-git\MovieApp\node_modules\request\node_modules\http-signature\lib'
  ERROR in ./node_modules/tunnel-agent/index.js
  Module not found: Error: Can't resolve 'http' in 'E:\moj-git\MovieApp\node_modules\tunnel-agent'
  ERROR in ./node_modules/forever-agent/index.js
  Module not found: Error: Can't resolve 'https' in 'E:\moj-git\MovieApp\node_modules\forever-agent'
  ERROR in ./node_modules/request/request.js
  Module not found: Error: Can't resolve 'https' in 'E:\moj-git\MovieApp\node_modules\request'
  ERROR in ./node_modules/tunnel-agent/index.js
  Module not found: Error: Can't resolve 'https' in 'E:\moj-git\MovieApp\node_modules\tunnel-agent'
  ERROR in ./node_modules/forever-agent/index.js
  Module not found: Error: Can't resolve 'net' in 'E:\moj-git\MovieApp\node_modules\forever-agent'
  ERROR in ./node_modules/tough-cookie/lib/cookie.js
  Module not found: Error: Can't resolve 'net' in 'E:\moj-git\MovieApp\node_modules\tough-cookie\lib'
  ERROR in ./node_modules/tunnel-agent/index.js
  Module not found: Error: Can't resolve 'net' in 'E:\moj-git\MovieApp\node_modules\tunnel-agent'
  ERROR in ./node_modules/jsdom/lib/jsdom/living/file-api/Blob-impl.js
  Module not found: Error: Can't resolve 'os' in 'E:\moj-git\MovieApp\node_modules\jsdom\lib\jsdom\living\file-api'
  ERROR in ./node_modules/jsdom/lib/jsdom/living/navigator/NavigatorConcurrentHardware-impl.js
  Module not found: Error: Can't resolve 'os' in 'E:\moj-git\MovieApp\node_modules\jsdom\lib\jsdom\living\navigator'
  ERROR in ./node_modules/cssstyle/lib/CSSStyleDeclaration.js
  Module not found: Error: Can't resolve 'path' in 'E:\moj-git\MovieApp\node_modules\cssstyle\lib'
  ERROR in ./node_modules/jsdom/lib/api.js
  Module not found: Error: Can't resolve 'path' in 'E:\moj-git\MovieApp\node_modules\jsdom\lib'
  ERROR in ./node_modules/jsdom/lib/jsdom/utils.js
  Module not found: Error: Can't resolve 'path' in 'E:\moj-git\MovieApp\node_modules\jsdom\lib\jsdom'
  ERROR in ./node_modules/mime-types/index.js
  Module not found: Error: Can't resolve 'path' in 'E:\moj-git\MovieApp\node_modules\mime-types'
  ERROR in ./node_modules/combined-stream/lib/combined_stream.js
  Module not found: Error: Can't resolve 'stream' in 'E:\moj-git\MovieApp\node_modules\combined-stream\lib'
  ERROR in ./node_modules/delayed-stream/lib/delayed_stream.js
  Module not found: Error: Can't resolve 'stream' in 'E:\moj-git\MovieApp\node_modules\delayed-stream\lib'
  ERROR in ./node_modules/iconv-lite/lib/streams.js
  Module not found: Error: Can't resolve 'stream' in 'E:\moj-git\MovieApp\node_modules\iconv-lite\lib'
  ERROR in ./node_modules/iconv-lite/lib/extend-node.js
  Module not found: Error: Can't resolve 'stream' in 'E:\moj-git\MovieApp\node_modules\iconv-lite\lib'
  ERROR in ./node_modules/isstream/isstream.js
  Module not found: Error: Can't resolve 'stream' in 'E:\moj-git\MovieApp\node_modules\isstream'
  ERROR in ./node_modules/jsprim/node_modules/assert-plus/assert.js
  Module not found: Error: Can't resolve 'stream' in 'E:\moj-git\MovieApp\node_modules\jsprim\node_modules\assert-plus'
  ERROR in ./node_modules/request/request.js
  Module not found: Error: Can't resolve 'stream' in 'E:\moj-git\MovieApp\node_modules\request'
  ERROR in ./node_modules/request/node_modules/assert-plus/assert.js
  Module not found: Error: Can't resolve 'stream' in 'E:\moj-git\MovieApp\node_modules\request\node_modules\assert-plus'
  ERROR in ./node_modules/sshpk/lib/ed-compat.js
  Module not found: Error: Can't resolve 'stream' in 'E:\moj-git\MovieApp\node_modules\sshpk\lib'
  ERROR in ./node_modules/sshpk/node_modules/assert-plus/assert.js
  Module not found: Error: Can't resolve 'stream' in 'E:\moj-git\MovieApp\node_modules\sshpk\node_modules\assert-plus'
  ERROR in ./node_modules/verror/node_modules/assert-plus/assert.js
  Module not found: Error: Can't resolve 'stream' in 'E:\moj-git\MovieApp\node_modules\verror\node_modules\assert-plus'
  ERROR in ./node_modules/forever-agent/index.js
  Module not found: Error: Can't resolve 'tls' in 'E:\moj-git\MovieApp\node_modules\forever-agent'
  ERROR in ./node_modules/tunnel-agent/index.js
  Module not found: Error: Can't resolve 'tls' in 'E:\moj-git\MovieApp\node_modules\tunnel-agent'
  ERROR in ./node_modules/request/request.js
  Module not found: Error: Can't resolve 'zlib' in 'E:\moj-git\MovieApp\node_modules\request'
  </code></pre>