Trouble importing Web3 in React.js

PosighdunPosighdun Member Posts: 2
edited May 2017 in Smart Contracts and Dapps
I'm trying to connect my react app to a smart contract running on testrpc. But when I put
import Web3 from 'web3'
into the App.js file and save, the app running on localhost in my browser gives me the error:
Error in /Users/my_username/~/web3/lib/web3.js
Module not found: 'json' in /Users/my_username/node_modules/web3/lib

@ /Users/my_username/~/web3/lib/web3.js 37:14-39

Also I have
"web3": "^0.19.0"
in my package.json dependencies. I can't figure out what's wrong for the life of me.


  • apmangaapmanga Member Posts: 1
    Think it's pretty late and you might have figured this out already, but for sake of others coming across this question, you would have to install dependencies listed in your package.json (i..e., 'web3')

    Do 'npm install' and it should work fine.
Sign In or Register to comment.