when I run truffle compile, truffle migrate successfully and then truffle console gives me the following error. strong text

**Enexpected error: Cannot provision contracts while instantiating the console.
Error: Cannot parse .DS_Store: Unexpected token  in JSON at position 0
    at /usr/local/lib/node_modules/truffle/lib/repl.js:69:27
    at tryToString (fs.js:447:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:434:12)
truffle(development)> TypeError: Cannot read property 'forEach' of undefined
    at TruffleInterpreter.resetContractsInConsoleContext (/usr/local/lib/node_modules/truffle/lib/repl.js:95:17)
    at /usr/local/lib/node_modules/truffle/lib/repl.js:44:12**

UPDATE: I solved this problem by pulling a fresh copy of my code from github. And then in my new project directory, I re did npm install. Hope this is helpful

  • No 100% sure but I think you have the MacOS metadata folder file [.DS_Store] somewhere it shouldn't be. Try to find in one of the truffle folders (build, contract, migration or test). Otherwise, it's always good to give OS and software versions. Commented Mar 5, 2017 at 23:23
  • hi @gjeanmart I have no such file. there is some other people having the same problem. Maybe its my version of truffle. maybe I need to wait for a new version to be released. Is there a way to downgrade my truffle? Commented Mar 7, 2017 at 2:19

5 Answers 5


.DS_Store is a hidden file created by macOS operating system. Operating system may automatically create this file under various circumstances. I assume that Truffle has a bug that instead of reading the specific files produced by a truffle compile it tries to read all files in the configured directory.

Truffle tries to read compiler outputted JSON format files. Naturally .DS_Store is not a file of a such a format making truffle to crash.

The correct course of action here is to

  • Delete .DS_Store file or makes sure truffle compile output goes into a clean directory. .DS_Store might not be visible in Finder listing, as its a special file, so it is better to delete with from the command line with ls -la and rm commands.

  • File a bug against truffle

  • Why was this downvoted? It looks like the right answer. Would it not be better to comment if you feel it's not?
    – xxx
    Commented Mar 9, 2017 at 18:59

Do not pull your code again from GH.

Do not reinstall npm.

Delete build/contracts directory. This is not dangerous because it gets recreated during compilation.

  • This worked, probably the best option assuming you have not already deployed to testnet/mainnet.
    – David T
    Commented Dec 17, 2018 at 21:29


find . -name ".DS_Store" -delete

Before running

truffle console

(Problem still exists in Truffle v4.1.6 (core: 4.1.6))


thanks for all you input. I fixed the problem by asking the main developers of truffle. The told me to npm install again in the new directory. It works


I had the same problem. I fixed it by deleting all the .DS_Store files in all the truffle directories. Below is what I did, it fixed my problem.

    Mac-sashi:dapp-experiments sashi$ ls -a
    .           app         package-lock.json
    ..          box-img-lg.png      package.json
    .DS_Store       box-img-sm.png      test
    .babelrc        build           truffle-box.json
    .eslintignore       contracts       truffle.js
    .eslintrc       index.html      webpack.config.js
    .gitignore      migrations
    README.md       node_modules
    Mac-sashi:dapp-experiments sashi$ rm app/.DS_Store 
    Mac-sashi:dapp-experiments sashi$ rm .DS_Store 
    Mac-sashi:dapp-experiments sashi$ rm test/.DS_Store 
    Mac-sashi:dapp-experiments sashi$ rm build/.DS_Store 
    Mac-sashi:dapp-experiments sashi$ rm contracts/.DS_Store 
    Mac-sashi:dapp-experiments sashi$ rm migrations/.DS_Store 
    Mac-sashi:dapp-experiments sashi$ rm node_modules/.DS_Store

Edit:I realized that everytime the directory is opened using finder, MacOs will generate .DS_Store file in the directory. So better doo all the operations using terminal.

  • I realized that everytime the directory is opened using finder, MacOs will generate .DS_Store file in the directory. So better doo all the operations using terminal.
    – Sashi
    Commented Dec 7, 2017 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.