Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Module Not Found with Angular 6 #12

Open
anthonyikeda opened this issue Jun 16, 2018 · 2 comments
Open

Getting Module Not Found with Angular 6 #12

anthonyikeda opened this issue Jun 16, 2018 · 2 comments

Comments

@anthonyikeda
Copy link

I've added the module to my project:
yarn add macaroons.js

And the module gets added and I can use it in my Components:

import { MacaroonsBuilder } from 'macaroons.js';
...
    let macaroon = MacaroonsBuilder.create('http://localhost:4200', 'apples', 'working-ui');

But when I go to build the project I get

ERROR in ./node_modules/macaroons.js/lib/CryptoTools.js
Module not found: Error: Can't resolve 'crypto' in '\node_modules\macaroons.js\lib'

I've tried patching with the following approach: angular/angular-cli#1548 (comment)

But so far no luck.

$ ng -version
Angular CLI: 6.0.8
Node: 10.4.1
OS: win32 x64
Angular: 6.0.5
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.8
@angular-devkit/build-angular     0.6.8
@angular-devkit/build-optimizer   0.6.8
@angular-devkit/core              0.6.8
@angular-devkit/schematics        0.6.8
@angular/cdk                      6.2.1
@angular/cli                      6.0.8
@angular/material                 6.2.1
@ngtools/webpack                  6.0.8
@schematics/angular               0.6.8
@schematics/update                0.6.8
rxjs                              6.2.1
typescript                        2.7.2
webpack                           4.8.3

OS: Windows 10
Node Version: v10.4.1

@nitram509
Copy link
Owner

nitram509 commented Jan 7, 2021

Hi @anthonyikeda ,
thank you, for your comprehensive issue reported.
I'm sorry for the long delay ... but the answer to your question is likely simple.
The dependent 'crypto' library is provided by Node.JS core libs.
Currently, there's no support for browser-based applications, which do support this lib, out of the box.
Maybe there's a polyfill or siimlar replacement for such.

Currently, I have no spare time available to work on this issue.

@chris-aeviator
Copy link

chris-aeviator commented Apr 8, 2021

I fixed this with webpack by using resolve-> alias as described in here https://sanchit3b.medium.com/how-to-polyfill-node-core-modules-in-webpack-5-905c1f5504a0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants