Truffle: SyntaxError: Unexpected string in JSON at position

Created on 30 Jan 2019  路  5Comments  路  Source: trufflesuite/truffle

Issue

I have been receiving a SyntaxError: Unexpected string in JSON at position... running truffle test. This occurs after contracts are compiled, and even with an empty test file! I have also tried deleting my node modules and running npm i in case there is a conflict there.

Steps to Reproduce

truffle test

Actual Results

/anaconda/lib/node_modules/truffle/build/cli.bundled.js:629262
    var artifact = JSON.parse(
                        ^
undefined:1865
}                "name": "address",
                 ^

SyntaxError: Unexpected string in JSON at position 62142
    at JSON.parse (<anonymous>)
    at FS.getContractName (/anaconda/lib/node_modules/truffle/build/cli.bundled.js:629262:25)
    at FS.require (/anaconda/lib/node_modules/truffle/build/cli.bundled.js:629237:28)
    at Resolver.require (/anaconda/lib/node_modules/truffle/build/cli.bundled.js:260204:25)
    at TestResolver.require (/anaconda/lib/node_modules/truffle/build/cli.bundled.js:459761:30)
    at Object.require (/anaconda/lib/node_modules/truffle/build/cli.bundled.js:421918:38)
    at ResolverIntercept.require (/anaconda/lib/node_modules/truffle/build/cli.bundled.js:628274:32)
    at /Users/isaacsultan/PartialF/mvp/migrations/1_initial_migration.js:1:28
    at ContextifyScript.Script.runInContext (vm.js:59:29)
    at ContextifyScript.Script.runInNewContext (vm.js:65:15)
    at /anaconda/lib/node_modules/truffle/build/cli.bundled.js:470837:14
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)

Environment

  • Operating System: macOS
  • Ethereum client: ganache0-cli
  • Truffle version: Truffle v5.0.0
  • node version: v8.9.3
  • npm version: 6.5.0
bug error better truffle test

All 5 comments

Hey @isaacsultan, what happens when you delete your build folder and try again?
Also, you should consider getting the most recent Truffle (5.0.3). If you are still having the issue, is your code available somewhere to take a look at?

Yes, @isaacsultan @eggplantzzz this issue is happening mostly in cases when your build file has some issues. (Mostly, when you're copying something from there or editing it for some reason, any typo will cause this issue.

@eggplantzzz Issue not resolved by deletion of build folder and recompile, and @madjarevicn no changes made to within build files. However, glad to say the issue has resolved since updating truffle!

@isaacsultan you reopened this, why? Is the problem still happening on later versions? Thanks!

Closing for issue maintenance. Feel free to get back to us if you need this re-opened!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ysfAskri picture ysfAskri  路  4Comments

oed picture oed  路  3Comments

jleeh picture jleeh  路  3Comments

timothywangdev picture timothywangdev  路  3Comments

rjl493456442 picture rjl493456442  路  4Comments