Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't connect with Node.js #1051

Closed
KenoLeon opened this issue Sep 17, 2017 · 4 comments
Closed

Can't connect with Node.js #1051

KenoLeon opened this issue Sep 17, 2017 · 4 comments

Comments

@KenoLeon
Copy link

KenoLeon commented Sep 17, 2017

I have parity running on one terminal with:
parity --chain kovan ui

Then on Atom I try to attach with:

 Web3 = require("web3")
 web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
 console.log(web3.eth.blockNumber)

When I run it with atom-runner or a node terminal I get undefined.

Running Parity/v1.6.10-stable,node 8.5.0/ web3 1.0.0-beta.20

@KenoLeon KenoLeon changed the title Can't connect with Node. Can't connect with Node.js Sep 17, 2017
@KenoLeon
Copy link
Author

KenoLeon commented Sep 17, 2017

Of course I figured it out after a minute of posting the issue:

npm installs version 1.0 of web3, uninstalling it and installing v '0.20.2' resolved my problem.

@albomo
Copy link

albomo commented May 16, 2018

KenoLeon, Hi, how did you uninstall it and install the lower version?
Have problems seems the same with that yours.

@KenoLeon
Copy link
Author

@albomo check:

https://medium.com/@k3no/ethereum-tokens-smart-contracts-a263b43d4c54

Basically npm view web3 versions to view versions and then something like npm install web3@0.20.2 to install , also check that your are on the latest parity release, things change so fast that I'd recommend you check the beta changelogs .

@fainashalts
Copy link

I see this is an older thread, but I wanted to ask -- the web3 documentation says that HttpProvider is deprecated, so I wonder if that's why it doesn't work with the newer versions of web3. It looks like this is only as related to subscriptions, so I guess its not that important if you're not using those?

But I wonder if the proper approach is to use the newest version of web3 and use websockets instead? See the discussion of these different methods in the web3 documentation: https://web3js.readthedocs.io/en/1.0/web3.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants