I am receiving a "not defined" error when trying to access the web3 object in Chrome terminal. My current setup:
- running testrpc
- web3 object successfully instantiated in App.js
- built app using React
- using Chrome incognito window
I would like to be able to access my contract through the Chrome terminal but when I try to set the web3
variable in terminal here:
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
I receive the error Uncaught ReferenceError: Web3 is not defined
in Chrome console.
In my App.js file, I have the following: import Web3 from 'web3';
. When I set the variable in App.js, console.log(web3)
outputs the object correctly. When I try to add import Web3 from 'web3';
in Chrome terminal, I get the error Uncaught SyntaxError: Unexpected token import
.
After doing a little research it looks like I might need to use require and Browserify to use the web3 library correctly in Chrome terminal. Are there other ways to use the web3js in React in Chrome terminal using my current setup?