Skip to content
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
@hbthegreat

Description

@hbthegreat

Expected behavior

  1. Create a brand new Angular Application
  2. npm install web3
  3. 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');
}
  1. 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

  1. ng new my-first-project (needs angular cli)
  2. cd my-first-project
  3. Edit app.component as above
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions