You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ahhh i think i found your issue, this is a mismatch issue with the angular-cli-files default browser.js settings and is something you have to fix to get web3 to work on angular apps.
#5368
Closed
araaan12 opened this issue
Aug 21, 2022
· 1 comment
ahhh i think i found your issue, this is a mismatch issue with the angular-cli-files default browser.js settings and is something you have to fix to get web3 to work on angular apps.
if you create a file called patch.js in the root of the angular app
const fs = require('fs');
const f = 'node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js';
fs.readFile(f, 'utf8', function (err, data) {
if (err) {
return console.log(err);
}
var result = data.replace(/node: false/g, 'node: {crypto: true, stream: true}');
fs.writeFile(f, result, 'utf8', function (err) {
if (err) return console.log(err);
});
});
then in your package.json under scripts add "postinstall": "node patch.js"
run npm install again and then ng build will all work and you shouldn't have anymore issues.
This is because we have to replace the node:false in the /angular-cli-files/models/webpack-configs/browser.js with 'node: {crypto: true, stream: true}' to allow web3 to work with angular (as they enforce node: false.)
I just did that and boom worked on your repo:
I will look further into this and try to find a way we can fix this within the install of web3 as its pretty annoying to have to add the above and hard to know how to sort if you not came across it before.
ahhh i think i found your issue, this is a mismatch issue with the angular-cli-files default
browser.js
settings and is something you have to fix to getweb3
to work on angular apps.if you create a file called
patch.js
in the root of the angular appthen in your
package.json
underscripts
add"postinstall": "node patch.js"
run
npm install
again and thenng build
will all work and you shouldn't have anymore issues.This is because we have to replace the
node:false
in the/angular-cli-files/models/webpack-configs/browser.js
with'node: {crypto: true, stream: true}'
to allowweb3
to work with angular (as they enforcenode: false
.)I just did that and boom worked on your repo:
I will look further into this and try to find a way we can fix this within the install of
web3
as its pretty annoying to have to add the above and hard to know how to sort if you not came across it before.Cheers @RohanKapurDEV
Originally posted by @joshstevens19 in #2260 (comment)
The text was updated successfully, but these errors were encountered: