This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Angular 16+ and Web3js 4.0+ problem solving #6326
Closed
Description
Expected behavior
- Create a brand new Angular Application
npm install web3
- Try a simple test in
app.component
import { Component } from '@angular/core';
import { Web3 } from 'web3';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent {
Web3 = new Web3('http://127.0.0.1:8545');
}
- Able to use the library
Actual behavior
- The first error that is run into is
/node_modules/isomorphic-ws/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag
- So I added this to tsconfig as mentioned in many places online
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
- Still not working and getting errors like:
Uncaught ReferenceError: process is not defined
- I have tried almost every single thing I can find online but haven't had any luck.
Steps to reproduce the behavior
ng new my-first-project
(needs angular cli)- cd my-first-project
- Edit app.component as above
- ng serve
Logs
Included above.
Environment
@angular version ^16.1.0 (the latest version)
web3 version ^4.0.3
npm version 9.8.1
node versoin 18.15.0