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

cannot compile angular 8 app after import web3 ver "^1.2.1" #3121

Closed
nasraldin opened this issue Oct 10, 2019 · 1 comment
Closed

cannot compile angular 8 app after import web3 ver "^1.2.1" #3121

nasraldin opened this issue Oct 10, 2019 · 1 comment

Comments

@nasraldin
Copy link

Description

I create a new angular 8 app with any third part libs then I install web3 lib by npm install web3 this will install the latest version of web3 "^1.2.1" after that I import Web3 from 'web3';
in my ng Component just simple implement of web3 calling

// this my Component implement of web3

import { Component, OnInit } from '@angular/core';
import { IEnsRegistrar } from '../../ens-registrar';
import Web3 from 'web3';
import { HttpClient } from '@angular/common/http';

declare let window: any;

@component({
selector: 'app-blank',
templateUrl: './blank.component.html',
styleUrls: ['./blank.component.css']
})
export class BlankComponent implements OnInit {

private web3: Web3;

constructor(private http: HttpClient) {
window.addEventListener('load', event => {});
}

ngOnInit() {
if (window.ethereum) {
console.log('Detect MetaMask has successfully connected.');
// use MetaMask's provider
this.web3 = new Web3(window.ethereum);

  // get permission to access accounts
  window.ethereum.enable();
}

}
}

Expected behavior

compile success app without any compiling errors and show the log msg in console "Detect MetaMask has successfully connected"

Actual behavior

WARNING in ./node_modules/web3-eth-accounts/src/scrypt.js 17:50-60
Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/asn1.js/lib/asn1/api.js
Module not found: Error: Can't resolve 'vm' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\asn1.js\lib\asn1'

ERROR in ./node_modules/eth-lib/lib/bytes.js
Module not found: Error: Can't resolve 'crypto' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\eth-lib\lib'
ERROR in ./node_modules/scryptsy/lib/scryptSync.js
Module not found: Error: Can't resolve 'crypto' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\scryptsy\lib'
ERROR in ./node_modules/scryptsy/lib/scrypt.js
Module not found: Error: Can't resolve 'crypto' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\scryptsy\lib'
ERROR in ./node_modules/scryptsy/lib/utils.js
Module not found: Error: Can't resolve 'crypto' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\scryptsy\lib'
ERROR in ./node_modules/web3-eth-accounts/node_modules/eth-lib/lib/bytes.js
Module not found: Error: Can't resolve 'crypto' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\web3-eth-accounts\node_modules\eth-lib\lib'
ERROR in ./node_modules/web3-eth-accounts/src/index.js
Module not found: Error: Can't resolve 'crypto' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\web3-eth-accounts\src'
ERROR in ./node_modules/web3-eth-accounts/src/scrypt.js
Module not found: Error: Can't resolve 'crypto' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\web3-eth-accounts\src'
ERROR in ./node_modules/web3-providers-http/src/index.js
Module not found: Error: Can't resolve 'http' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\web3-providers-http\src'
ERROR in ./node_modules/xhr2-cookies/dist/xml-http-request.js
Module not found: Error: Can't resolve 'http' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\xhr2-cookies\dist'9m
ERROR in ./node_modules/web3-providers-http/src/index.js
Module not found: Error: Can't resolve 'https' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\web3-providers-http\src'
ERROR in ./node_modules/xhr2-cookies/dist/xml-http-request.js
Module not found: Error: Can't resolve 'https' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\xhr2-cookies\dist'
ERROR in ./node_modules/xhr2-cookies/dist/xml-http-request.js
Module not found: Error: Can't resolve 'https' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\web3-providers-http\src'
ERROR in ./node_modules/xhr2-cookies/dist/xml-http-request.js
Module not found: Error: Can't resolve 'https' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\xhr2-cookies\dist'
ERROR in ./node_modules/xhr2-cookies/dist/xml-http-request.js
Module not found: Error: Can't resolve 'os' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\xhr2-cookies\dist'
ERROR in ./node_modules/browserify-sign/browser/index.js
Module not found: Error: Can't resolve 'stream' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\browserify-sign\browser'
ERROR in ./node_modules/cipher-base/index.js
Module not found: Error: Can't resolve 'stream' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\cipher-base'
ERROR in ./node_modules/hash-base/index.js
Module not found: Error: Can't resolve 'stream' in 'D:\source\github\repos\ens_contract_events\ens_contract_events\node_modules\hash-base'
i 「wdm」: Failed to compile.

Steps to reproduce the behavior

Error Logs

Gists

Versions

@nivida
Copy link
Contributor

nivida commented Oct 11, 2019

Duplication of #3018

@nivida nivida closed this as completed Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants