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
{{ message }}
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+44-1
Original file line number
Diff line number
Diff line change
@@ -104,11 +104,54 @@ If you are using the types in a `commonjs` module, like in a Node app, you just
104
104
## Trouble shooting and known issues.
105
105
106
106
### Web3 and Angular
107
+
108
+
### New solution
109
+
110
+
If you are using Angular version >11 and run into an issue building, the old solution below will not work. This is because polyfills are not included in the newest version of Angular.
111
+
112
+
- Install the required dependencies within your angular project:
- Within `tsconfig.json` add the following `paths` in `compilerOptions` so Webpack can get the correct dependencies
119
+
120
+
```typescript
121
+
{
122
+
"compilerOptions": {
123
+
"paths": {
124
+
"crypto": ["./node_modules/crypto-browserify"],
125
+
"stream": ["./node_modules/stream-browserify"],
126
+
"assert": ["./node_modules/assert"],
127
+
"http": ["./node_modules/stream-http"],
128
+
"https": ["./node_modules/https-browserify"],
129
+
"os": ["./node_modules/os-browserify"],
130
+
}
131
+
}
132
+
```
133
+
134
+
- Add the following lines to `polyfills.ts` file:
135
+
136
+
```typescript
137
+
import { Buffer } from'buffer';
138
+
139
+
(window as any).global=window;
140
+
global.Buffer= Buffer;
141
+
global.process= {
142
+
env: { DEBUG:undefined },
143
+
version:'',
144
+
nextTick:require('next-tick')
145
+
} as any;
146
+
```
147
+
148
+
### Old solution
149
+
107
150
If you are using Ionic/Angular at a version >5 you may run into a build error in which modules `crypto` and `stream` are `undefined`
108
151
109
152
a work around for this is to go into your node-modules and at `/angular-cli-files/models/webpack-configs/browser.js` change the `node:false` to `node: {crypto:true, stream:true}` as mentioned [here](https://github.com/ethereum/web3.js/issues/2260#issuecomment-458519127)
110
153
111
-
Another variation of this problem was an issue opned on angular-cli: https://github.com/angular/angular-cli/issues/1548
154
+
Another variation of this problem was an [issue opned on angular-cli](https://github.com/angular/angular-cli/issues/1548)
0 commit comments