Skip to content

Angular & native crypto moduleΒ #262

@qortex

Description

@qortex

I understand the move to 4.0.0 uses native crypto module.

As a result, with my Angular app, I get the error message below when building.

As I understand, the crypto module needs to be explicitly bundled by Webpack as it's not by default with Angular config.

Does anyone already know how to do that? I'm not that familiar with Webpack and would appreciate any hint.

WARNING in ./node_modules/crypto-js/core.js
Module not found: Error: Can't resolve 'crypto' in '/tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/node_modules/crypto-js'
resolve 'crypto' in '/tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/node_modules/crypto-js'
  Parsed request is a module
  using description file: /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/node_modules/crypto-js/package.json (relative path: .)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      looking for modules in /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8
        using description file: /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/package.json (relative path: .)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/package.json (relative path: ./crypto)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/crypto doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/crypto.ts doesn't exist
            .tsx
              Field 'browser' doesn't contain a valid alias configuration
              /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/crypto.tsx doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/crypto.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/crypto.js doesn't exist
            as directory
              /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/crypto doesn't exist
      /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/node_modules/crypto-js/node_modules doesn't exist or is not a directory
      /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/node_modules/node_modules doesn't exist or is not a directory
      /tmp/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/node_modules
        using description file: /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/package.json (relative path: ./node_modules/crypto)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/node_modules/crypto doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/node_modules/crypto.ts doesn't exist
            .tsx
              Field 'browser' doesn't contain a valid alias configuration
              /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/node_modules/crypto.tsx doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/node_modules/crypto.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/node_modules/crypto.js doesn't exist
            as directory
              /tmp/build_fa83cfc445ddeaf2cca1c12ae9bcefc8/node_modules/crypto doesn't exist

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions