0

I am trying to load web3 library after installing it via command prompt. However, looks like it is not loading properly as it is not showing all the details for Ethereum ecosystem (ex. unitmap of various ether units).

============================================================================

C:\WINDOWS\system32>node -v
v10.6.0

C:\WINDOWS\system32>npm -v
6.1.0

C:\WINDOWS\system32>node

var Web3 = require('web3'); undefined

Web3 { [Function: Web3] providers: { HttpProvider: [Function: HttpProvider], IpcProvider: [Function: IpcProvider] } }

var url = "https://mainnet.infura.io/pK8qXfQRfbImxGXdDPfC" undefined

var web3 = new Web3(url) undefined

var address = '0x281055Afc982d96fAB65b3a49cAc8b878184Cb16' undefined

web3.eth.getBalance(address, (err, bal) => {balance = bal})

TypeError: this.provider.sendAsync is not a function at RequestManager.sendAsync (C:\WINDOWS\system32\node_modules\web3\lib\web3\requestmanager.js:80:19) at Eth.send [as getBalance] (C:\WINDOWS\system32\node_modules\web3\lib\web3\method.js:141:42)

============================================================================

First, I downloaded web3 via following command, after that I tried to load the library:

============================================================================ C:\WINDOWS\system32> npm install ethereum/web3.js --save npm WARN system32@1.0.0 No description

npm WARN system32@1.0.0 No repository field.

Is it happening because I haven't specified a repository while doing "npm init" command?

If it is helpful, I have provided the response as well for "npm init" command.

============================================================================

C:\WINDOWS\system32>npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (system32)
version: (1.0.0)
description:
git repository:
keywords:
author:
license: (ISC)
About to write to C:\WINDOWS\system32\package.json:

{
  "name": "system32",
  "version": "1.0.0",
  "main": "index.js",
  "dependencies": {
    "ganache-cli": "^6.1.5",
    "web3": "github:ethereum/web3.js"
  },
  "devDependencies": {
    "mocha": "^5.2.0"
  },
  "scripts": {
    "test": "mocha"
  },
  "author": "",
  "license": "ISC",
  "description": ""
}


Is this OK? (yes) yes

============================================================================

Any advice would be appreciated. Thanks in advance.

  • I think you want npm install web3, not npm install ethereum/web3.js, but I suspect both work. Your first code snippet makes it look like web3 is indeed installed. Can you explain why you think something is wrong? – smarx Jul 8 '18 at 18:28
  • Can you share the rest of your code? (What provider are you using when you create your web3 instance? E.g. var web3 = new Web3(...) – smarx Jul 8 '18 at 19:14
  • Just updated the original post with the rest of the code. Thanks. – James11 Jul 8 '18 at 21:58
  • I get the same error as you when I used npm install ethereum/web3.js, but I don't get that error if I use npm install web3. – smarx Jul 8 '18 at 22:08
  • what's the version of web3 that you've installed? 0.20.0 or 1.0.0 Beta? You can check using below javascript in the console. var version = web3.version.api; console.log(version); – Bharat Mallapur Jul 8 '18 at 22:19
1

I had same issue with npm install web3. but after executed command of • npm install --global --production windows-build-tools, executing npm install web3 without error but when move into node console, require('web3') gets error. finally I found npm install web3 did not download web3.js and web3.min.js. but change to use npm install ethereum/web3.js works for me.

0

To install web3, use npm install web3.

(I'm not entirely sure what npm install ethereum/web3.js is doing, but it seems to cause that error.)

  • Thanks @smarx for the reply. I tried to use "npm install web3" but am having the same error. I am not sure why is it working in your case and not in mine. – James11 Jul 9 '18 at 15:24
  • Make sure to start from a clean environment. (Delete the node_modules directory, or better yet just start from a brand new directory.) – smarx Jul 9 '18 at 17:07

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.