3

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.

  • How do you inject web3 library? Can you show some code? The second error is related to the fact that you don't have bignumber.js which is used by web3. – Tek Jul 31 '17 at 12:58
  • @tek RunKit should already have all the modules loaded. I've never faced this error before with anything else I've tried on RunKit. I have updated the question with the code for the first error though. – ninesalt Jul 31 '17 at 14:02
  • Upgrade to Node 6.10 or 8.5 and use Web js version 1.9.0. – Ling Qing Meng Sep 18 '17 at 4:27
  • There's a thread here talking about the issue. Are you using webpack? That could be the cause. FWIW I'm having the same issue and haven't resolved it yet, but this is helping me get on the right track. – rhlsthrm Sep 21 '17 at 0:46
  • "web3 not working" is an awfully generic subject, and less likely to get people to pay attention to it than one that actually suggests more about the problem. – Fred Douglis Mar 19 '18 at 17:29
1

hey so basically along with npm install web3 you also need "npm install ethereum/web3.js" . This worked for me

0
npm install ethereum/web3.js

should solve your problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.