Ionic 4 can't find native Node module "crypto"

I just finished writing a simple encryption service for my app. When I try to run the app i get an error: “Cannot find module ‘crypto’”. I looked at the line in question:

import { createCipher, createDecipher } from 'crypto';

It seems fine to me and if click on the import reference I jump to the node code:

declare module "crypto" {
    import * as stream from "stream";

    export interface Certificate {
        exportChallenge(spkac: string | Buffer | NodeJS.TypedArray | DataView): Buffer;
        exportPublicKey(spkac: string | Buffer | NodeJS.TypedArray | DataView): Buffer;
        verifySpkac(spkac: Buf...

Has anyone experienced something similar and can anyone help me?

Ionic info:


   ionic (Ionic CLI)  : 4.0.1 (C:\Users\XY\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.11


   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0


   Android SDK Tools : 26.1.1
   NodeJS            : v10.0.0 (C:\Program Files\nodejs\node.exe)
   npm               : 5.6.0
   OS                : Windows 10


   ANDROID_HOME : C:\Users\XY\AppData\Local\Android\Sdk

Is this an npm package? If so, post your package.json and a link to the github please.

If this is for anything other than sheer amusement and/or education, please don’t. Writing cryptographic protocols is extremely difficult, and you should rely on as much well-tested code as possible, such as HTTPS.