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 [email protected] No description
npm WARN [email protected] 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.
npm install web3
, notnpm 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?web3
instance? E.g.var web3 = new Web3(...)
npm install ethereum/web3.js
, but I don't get that error if I usenpm install web3
.