I have a feeling this is going to be a forehead-slapper, but here goes...

I'm attempting to run Truffle's "Pet Shop" demo app on AWS. The truffle compile command ran fine, with a few non-fatal warnings but nothing major. It completed with...

Writing artifacts to ./build/contracts

...as expected. But truffle migrate is failing, and it seems to be not seeing the contents of the file successfully created at contracts/Migrations.json.

$ truffle migrate
Using network 'development'.
Error: Could not find built Migrations contract: Unexpected token  in JSON at position 0

However, the file is there, and seems fine. Any idea why this is failing?

Also worth noting: I've got two console windows running (both SSH'd into the same AWS EC2 instance), and the second of the two is running testrpc. It is "listening" and does tell me...

Listening on localhost:8545

...when I attempt the migration, but nothing beyond that.

Thanks for any nudge in the right direction!

  • 1
    I ran into a similar issue, but had switched to using Ganache. I was able to fix my migration issue by deleting ./build and re-compiling/migrating.
    – Justin
    Commented Apr 11, 2018 at 22:41
  • Thanks Justin - yup! Deleting the build subdirectory and re-running truffle compile and truffle migrate solved the problem. (I coulda sworn I'd done the same yesterday, but I guess not.) :) Commented Apr 12, 2018 at 23:29

3 Answers 3


you can delete your build directory and try again

rm -rf build
truffle compile
truffle migrate


rm -rf build && truffle compile && truffle migrate
  • This is STILL a problem today. Why does it do this? Does truffle know about this? It's very timewasting for developers.
    – Emobe
    Commented Jan 19, 2020 at 14:34
  • try becoming a core contributor and fix it 🤙 Commented Jan 22, 2020 at 14:02

truffle migrate --reset cleans up your build directory and builds your contracts again.


I ran in to the same issue as Jesse and I followed Harry's instructions on deleting the build directory and I recompiled and it was fine.

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.