The following example does not hang.
$ cat main.js
#!/usr/bin/env node
// vim: set noexpandtab tabstop=2:
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
web3.eth.getAccounts()
.then((accounts) => {
console.log(accounts);
})
But the following code hangs. Does anybody know why?
$ cat main.js
#!/usr/bin/env node
// vim: set noexpandtab tabstop=2:
const web3 = new (require('web3'))("ws://localhost:8545");
web3.eth.getAccounts()
.then((accounts) => {
console.log(accounts);
})