Skip to content

Instantly share code, notes, and snippets.

@niespodd
Last active October 15, 2025 02:48
Show Gist options
  • Save niespodd/1fa82da6f8c901d1c33d2fcbb762947d to your computer and use it in GitHub Desktop.
Save niespodd/1fa82da6f8c901d1c33d2fcbb762947d to your computer and use it in GitHub Desktop.

Revisions

  1. niespodd revised this gist Jan 24, 2021. No changes.
  2. niespodd revised this gist Jan 24, 2021. 1 changed file with 18 additions and 0 deletions.
    18 changes: 18 additions & 0 deletions patch.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,20 @@
    // Angular >= 11
    const fs = require('fs')
    const f = 'node_modules/@angular-devkit/build-angular/src/webpack/configs/browser.js'

    fs.readFile(f, 'utf8', function(err, data) {
    if (err) {
    return console.log(err)
    }
    var result = data.replace(/node: false/g, 'node: {crypto: true, stream: true, fs: "empty"}')

    fs.writeFile(f, result, 'utf8', function(err) {
    if (err) return console.log(err)
    })
    });
    // ----

    // For Angular <11
    const fs = require('fs');
    const f = 'node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js';

    @@ -11,3 +28,4 @@ fs.readFile(f, 'utf8', function (err,data) {
    if (err) return console.log(err);
    });
    });
    // ----
  3. niespodd revised this gist May 6, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    {...
    "scripts": {
    "postinstall": "node patch.js",
    ...
    }
    }
  4. niespodd created this gist May 6, 2018.
    13 changes: 13 additions & 0 deletions patch.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    const fs = require('fs');
    const f = 'node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js';

    fs.readFile(f, 'utf8', function (err,data) {
    if (err) {
    return console.log(err);
    }
    var result = data.replace(/node: false/g, 'node: {crypto: true, stream: true}');

    fs.writeFile(f, result, 'utf8', function (err) {
    if (err) return console.log(err);
    });
    });