EOSIO / eosjs

General purpose library for the EOSIO blockchain.
http://eosio.github.io/eosjs
MIT License
1.43k stars 463 forks source link

TypeError: Cannot read property 'JsonRpc' of undefined #391

Closed yashwanth2804 closed 6 years ago

yashwanth2804 commented 6 years ago

Version of EOSJS beta

Describe the bug giving issue while I am providing process.env.REACT_APP_EOSIO_HTTP_URL valid end point

TypeError: Cannot read property 'JsonRpc' of undefined
new EOSIOClient
src/utils/eosio-client.js:8
   5 | console.log("^^^^^^^^^^^^^^^^^")
   6 | console.log(process.env.REACT_APP_EOSIO_HTTP_URL)
   7 | console.log("^^^^^^^^^^^^^^^^^")
>  8 | const rpc = new eosjs.Rpc.JsonRpc(process.env.REACT_APP_EOSIO_HTTP_URL)
   9 | const signatureProvider = new eosjs.SignatureProvider([process.env.REACT_APP_EOSIO_PRIVATE_KEY])
  10 | this.contractAccount = contractAccount
  11 | this.eos = new eosjs.Api({ rpc, signatureProvider })
iKest commented 6 years ago

use import {Rpc, SignatureProvider, Api} from 'eosjs'

and const rpc = new Rpc.JsonRpc( ... const sp = new SignatureProvider( ... const api = new Api( ...

yashwanth2804 commented 6 years ago

Still not working I changed to what u suggsted

jsonrpc That too while in import statement it showing thi warning

[ts]
Could not find a declaration file for module 'eosjs'.
iKest commented 6 years ago

need to see import eosjs code section

yashwanth2804 commented 6 years ago

Thank you I solved the issue, i un knowningly changed that [language] to typescript, with this effect every node module not imported after resetting worked fine . After changing from typescript to babel woking fine screenshot from 2018-10-10 17-50-42