Running truffle migrate with valid contract code started causing this error for me:

Writing artifacts to ./build/contracts

Using network 'development'.

Error: Could not find built Migrations contract: Unexpected token  in JSON at position 0
    at Object.lastCompletedMigration (/Users/joran/.nvm/versions/node/v8.11.1/lib/node_modules/truffle/build/webpack:/~/truffle-migrate/index.js:253:1)

This was caused by MacOS placing .DS_Store files inside the directories which truffle attempted to load as JSON.

Remove any .DS_Store files from your project:

find . -name '.DS_Store' -exec rm -r {} \;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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