I've been trying to use Web3 for a while now but I just can't get it to work. First I tried using it with angular 2 but whenever I included it and tried logging new Web3()
it said that one of the built-in packages in Web3 are missing. I reinstalled it a few times and it still didn't work.
I then tried it out on RunKit and I'm getting another error. This
is the code. Error is Cannot find module 'bignumber.js'
.
I know these two errors are probably unrelated but I figured I'd ask, maybe the solution to one is similar to the other's
Angular2 code:
import { Component } from '@angular/core';
import { NavController, ModalController } from 'ionic-angular';
import {ReceivePage} from '../receive/receive';
import * as Web3 from 'web3';
@Component({
selector: 'page-wallet',
templateUrl: 'wallet.html'
})
export class WalletPage {
web3Data: any;
constructor(public navCtrl: NavController, public modalCtrl: ModalController) {
this.web3Data = new Web3();
console.log(this.web3Data);
}
}
The error I get is
Cannot find module "web3-requestmanager"
Even though it should already be installed with Web3. I tried installing it alone and then I got the same error but with the name of a different package also included in Web3.
Best Answer
hey so basically along with npm install web3 you also need "npm install ethereum/web3.js" . This worked for me