Web3.js: Error after update rxjs v6

Created on 4 May 2018  路  5Comments  路  Source: ChainSafe/web3.js

After update angular and rxjs to v6

ng build

WARNING in ./node_modules/asn1.js/lib/asn1/api.js
Module not found: Error: Can't resolve 'vm' in '**\toh-pt6\node_modules\asn1.js\lib\asn1'

ERROR in ./node_modules/eth-lib/lib/bytes.js
Module not found: Error: Can't resolve 'crypto' in '*\toh-pt6\node_modules\eth-lib\lib'
ERROR in ./node_modules/web3-eth-accounts/node_modules/eth-lib/lib/bytes.js
Module not found: Error: Can't resolve 'crypto' in '
\toh-pt6\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 '
\toh-pt6\node_modules\web3-eth-accountssrc'
ERROR in ./node_modules/browserify-sign/browser/index.js
Module not found: Error: Can't resolve 'stream' in '
\toh-pt6\node_modules\browserify-sign\browser'
ERROR in ./node_modules/cipher-base/index.js
Module not found: Error: Can't resolve 'stream' in '
\toh-pt6\node_modules\cipher-base'
ERROR in ./node_modules/hash-base/index.js
Module not found: Error: Can't resolve 'stream' in '
*\toh-pt6\node_modules\hash-base'

Most helpful comment

The solution with the patch worked for me!
https://gist.github.com/niespodd/1fa82da6f8c901d1c33d2fcbb762947d

node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js
node: {crypto: true, stream: true}

All 5 comments

I'm having the same problem with similar libraries (like web3-eth-accounts). But I think that the problem comes from Angular upgrade and the webpack configuration.

Related issue here:
https://github.com/ethereum/web3.js/issues/1555

Workarounds suggested:

  • downgrade to Angular 5
  • try upgrading NodeJS version which includes crypto
  • download the build files from the releases page, copy the source to app/src and include it on scripts property of the angular.json config

I tried these, and they didn't work for me! From what I understand it's an issue with the typings file. Or a dependency.

My workaround was to downgrade to an older version of web3:
npm install [email protected]

Another workaround is the suggested here: angular/angular-cli#1548 (comment)
It replaces the webpack config of @angular/cli

The solution with the patch worked for me!
https://gist.github.com/niespodd/1fa82da6f8c901d1c33d2fcbb762947d

node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js
node: {crypto: true, stream: true}

@Pedro-vk Thanks. It is working for me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dzarezenko picture dzarezenko  路  3Comments

FradSer picture FradSer  路  3Comments

praveengupta0895 picture praveengupta0895  路  3Comments

oktapodia picture oktapodia  路  3Comments

xpepermint picture xpepermint  路  3Comments