4

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
net_version
eth_accounts

...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 Apr 11 '18 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.) :) – Jesse in Oregon Apr 12 '18 at 23:29
4

you can delete your build directory and try again

rm -rf build
truffle compile
truffle migrate

oneliner

rm -rf build && truffle compile && truffle migrate
1

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

0

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, privacy policy and cookie policy

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