Angular: Uncaught ReferenceError: process is not defined

Viewed 1968

I'm using igdb-api-node for my website that I'm developing. When adding this package I had issues with my node_modules.. that crypto, fs etc was not known. I googled around and I found a solution for this.

In my package.json I now have the following:

  "browser": {
    "crypto": false,
    "fs": false,
    "http": false,
    "https": false,
    "net": false,
    "path": false,
    "stream": false,
    "tls": false,
    "zlib": false
  }

This fixes the error, but the package is not been imported yet (import {igdb} from 'igdb-api-node'; - still gives an error). But when I start the server and go to my website I see the following error in the console and the website is not shown.

Uncaught ReferenceError: process is not defined
    at Object../node_modules/request/lib/helpers.js (vendor.js:176707)
    at __webpack_require__ (runtime.js:84)
    at Object../node_modules/request/index.js (vendor.js:175913)
    at __webpack_require__ (runtime.js:84)
    at Object../node_modules/igdb-api-node/lib/request-promise.js (vendor.js:170144)
    at __webpack_require__ (runtime.js:84)
    at Object../node_modules/igdb-api-node/lib/perform-request.js (vendor.js:169986)
    at __webpack_require__ (runtime.js:84)
    at Object../node_modules/igdb-api-node/lib/request-endpoint.js (vendor.js:170045)
    at __webpack_require__ (runtime.js:84)

For this I also googled around and I found multiple solution. E.g. by adding the following to my polyfills.ts and index.html

Poly:

if (global === undefined) { const global = window; }

index: (Tried both)

<!--<script>-->
    <!--var global = global || window;-->
    <!--var Buffer = Buffer || [];-->
    <!--var process = process || {-->
      <!--env: { DEBUG: undefined },-->
      <!--version: []-->
    <!--};-->
  <!--</script>-->
  <script>
    var global = global || window;
  </script>

But nothing is working.. after trying these I'm receiving errors about the buffer, but when installing the package the error persists. I have no clue to solve it..

I'm using the latest CLI (7.0.4) and angular/core (7.0.2). Updated all my packages this morning in the hope that it would solve the issue, but nope.

0 Answers
Related