Truffle: I successfully compile and migrate then when I try the console I get an error

Created on 15 Nov 2017  路  15Comments  路  Source: trufflesuite/truffle

  • [x] I've asked for help in the Truffle Gitter before filing this issue.

I successfully compile and migrate then when I try the console I get an error-

Unexpected error: Cannot provision contracts while instantiating the console.
Error: Cannot parse .DS_Store: Unexpected token in JSON at position 0
at /Users/ben/.nvm/versions/node/v8.8.1/lib/node_modules/truffle/build/cli.bundled.js:209525:27
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:513:3)

It also happens with other files I try and get the console running.. using two contracts on for a token and one for a token sale which creates the token instance. trying to link with web app.

Any help really appreciated. Tried various node fixes but no success yet..

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: MacOS Sierra
  • Truffle version: 3.4.11
  • Ethereum client: 1.7.2
  • node version: v8.8.1
  • npm version: 5.5.1

Most helpful comment

For anyone still having trouble with this; make sure your build folder (aka where the contract .json files are) ONLY contains .json files; for some reason truffle reads EVERY file. Any dangling .gitkeep, .DS_STORE, .something, random.file files will cause issues.

All 15 comments

Try deleting the .DS_Store folders from the projects directory, as a workaround.

Hi @beshogun, @kingcocomango Are you still seeing this issue on the latest Truffle (4.0.4) using the develop command (or in any other context?) Just starting out the Truffle team today and looking at few bugs . . .

I've generated some .DS_Store files in the contracts and tests folders (organically, by moving files via the UI) and then run through most of Truffle's commands, and done the same in the develop context. It's not crashing for me.

@cgewecke hi,i have tried run rm .DS_Store but it not work

@SephirothLT Hi. Which truffle version are you using? Could you run both:

npm list -g truffle
npm list truffle

@cgewecke thanks ,I just solved this problem, truffle version is 4.0.4
http://truffleframework.com/tutorials/debugging-a-smart-contract

Closing for housekeeping, but please open or open a new issue if anyone continues to see this.

Hey, could you tell me how the problem was solved. Seems like i'm having the exact same issue. Did DS_Store delete but that didn't work, i've also ensured that my version is 4.0.4

SyntaxError: Unexpected token < in JSON at position 2551 at JSON.parse (<anonymous>) at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:63221:33 at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:162329:9 at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:161676:16 at iteratorCallback (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:162253:13) at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:162161:16 at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:162326:13 at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:63214:15 at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:528:3)

@veebuv Thanks for reporting, re-opened and looking into this again. Could you provide some steps to reproduce this? Which command are you running when the error is triggered?

@veebuv Closing since it seems like you might have resolved this on your own. Please feel free to comment here if you're still seeing this and can show us a way to reproduce it.

truffle version: Truffle v4.1.13 (core: 4.1.13)
os: macOS Sierra 10.12

when i run this comment truffle migrate --reset for deploy a smart contract, but get the error message below:

`
192:client-server knight$ truffle migrate --reset
Compiling ./contracts/c1.sol...
Writing artifacts to ./build/contracts

Using network 'development'.

Running migration: 1_initial_migration.js

/usr/local/lib/node_modules/truffle/build/cli.bundled.js:101708
var artifact = JSON.parse(

undefined:1
b0VIM 7.4

SyntaxError: Unexpected token b in JSON at position 0
at JSON.parse ()
at FS.getContractName (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:101708:25)
at FS.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:101683:28)
at Resolver.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:59966:25)
at Object.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:69602:36)
at ResolverIntercept.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:199772:32)
at /Users/knight/Documents/geth/smart-contracts/hello/migrations/1_initial_migration.js:1:28
at ContextifyScript.Script.runInContext (vm.js:59:29)
at ContextifyScript.Script.runInNewContext (vm.js:65:15)
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:101624:14
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
`

It's the same for me like @JoyCood reported. Any advice on the issue?

Hi all, same issue as @zdesiree and @JoyCood. Anybody found a workaround and or a solution?

Hi everyone. I am getting this error. I'm trying to figure it out what is the cause, without any success.

Any ideas?

/usr/local/lib/node_modules/truffle/build/cli.bundled.js:101723
var artifact = JSON.parse(
^
undefined:1
0 info it worked if it ends with ok
^

SyntaxError: Unexpected token i in JSON at position 2
at JSON.parse ()
at FS.getContractName (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:101723:25)
at FS.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:101698:28)
at Resolver.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:59966:25)
at Object.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:69602:36)
at ResolverIntercept.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:197047:32)
at /kuantum-project/kuantum-project/blockchain/kuantum/migrations/1_initial_migration.js:3:30
at ContextifyScript.Script.runInContext (vm.js:59:29)
at ContextifyScript.Script.runInNewContext (vm.js:65:15)
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:101639:14
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)

Thanks in advance for any help

For anyone still having trouble with this; make sure your build folder (aka where the contract .json files are) ONLY contains .json files; for some reason truffle reads EVERY file. Any dangling .gitkeep, .DS_STORE, .something, random.file files will cause issues.

@cgewecke I am still having this issue, I tried removing all .DS_Store using:
find . -name ".DS_Store" -delete. I also tried creating another directory using truffle init and tried running truffle test but same error popped up.

Funny thing is that it was all working fine, until suddenly without changing a single thing this error popped up out of nowhere.

Was this page helpful?
0 / 5 - 0 ratings