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.
truffle test
/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)
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!