Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Unexpected token < in JSON at position 0 . #504

Closed
1 task
shdmitry2000 opened this issue Jul 19, 2017 · 4 comments
Closed
1 task

Unexpected token < in JSON at position 0 . #504

shdmitry2000 opened this issue Jul 19, 2017 · 4 comments

Comments

@shdmitry2000
Copy link

I am use last version of truffle .The deploy and test work perfectly.
When i use node with application i receive following problem:
Unexpected token < in JSON at position 0
The problem is connected to web3 version because i receive error web3 trying to get network id.
I upgraded web3 to version 0.18.4 and problem disapiared but now after upgrading one of module it's appiars again.

O am running on OSX

i am adding my dependence list from node (Local and global)
If somebody can help me.


Issue

What the issue is, in broad strokes.

Steps to Reproduce

Please provide the shortest amount of steps to reproduce your issue.

Expected Behavior

What you expected to happen.

Actual Results

What actually happened. Please give examples and support it with screenshots, copied output or error messages.

Environment

  • Operating System:
    uname -a
    Darwin MacBook-Pro 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64

  • Truffle version:
    truffle version
    Truffle v3.4.5 (core: 3.4.5)
    Solidity v0.4.11 (solc-js)

  • Ethereum client:

  • node version:
    node -v
    v8.1.4

  • npm version:
    npm -v
    5.0.3
    npm_global_list.txt
    npm_lis_ver.txt

@shdmitry2000
Copy link
Author

shdmitry2000 commented Jul 19, 2017

@shdmitry2000
Copy link
Author

I am use last version of truffle .The deploy and test work perfectly.
When i use node with application i receive following problem:
Unexpected token < in JSON at position 0
The problem is connected to web3 version because i receive error web3 trying to get network id.
I upgraded web3 to version 0.18.4 and problem disapiared but now after upgrading one of module it's appiars again.

@crazyrabbitLTC
Copy link

As a note I had this error and fixed it myself. The problem was that my contract (as defined in the .sol file) had a different name than the solidity file itself. So for example:

FirstContract.sol

and inside that file:

contract MyFirstContract () {}......

It seems that the contract name and the file name need to be the same. Not sure how the behavior will change when there are more than one contracts in the file, however this fixed the error for me.

@kuzdogan
Copy link

This seem to happen when the json parser expects a json but receives a different format. In this case it's probably getting an html error response.

One must look deeper and find the underlying issue. It could be a name mismatch as the above comment, or that contract instance is not actually deployed in the current network, even thought it's deployment info is stored in its build .json file.

In my case I deployed a contract to a ganache network. When I reset the network to the genesis state, Truffle calls tries to call the method again for the saved contract address but does not receive a proper response.

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

No branches or pull requests

3 participants