I am trying to compile my smart contracts using truffle pet-shop. I have the following contract in directory election/contracts/election.sol ;

pragma solidity >=0.4.0 <0.6.0;
contract Election{
    string public candidate;
    constructor() public{

The migration file to deploy contracts in directory election/migrations/2_deploy_contracts1.js is as follows;

var Election1=artifacts.require("election.sol");

I am using the following command to migrate the contracts:

truffle migrate

And I am getting the following results:

Compiling your contracts...
> Compiling .\contracts\Election.sol
> Compiling .\contracts\election.sol
> Artifacts written to D:\Notes\BCS\Semester 8\FYP\Practise Coding\dapp university 2 hr video code\election\build\contracts
> Compiled successfully using:
   - solc: 0.5.8+commit.23d335f2.Emscripten.clang

Starting migrations...
> Network name:    'development'
> Network id:      5777
> Block gas limit: 0x6691b7

Error: Error: Migration D:\Notes\BCS\Semester 8\FYP\Practise Coding\dapp university 2 hr video code\election\migrations\2_deploy_contracts1.js invalid or does not take any parameters
    at Object.run (C:\Users\mk141\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-migrate\index.js:92:1)
    at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.0.30 (core: 5.0.30)
Node v10.16.1

Its also compiling Election.sol because I renamed election.sol to Election.sol and it stores election.sol in cache perhaps.

As you can see above its giving Error:Migration 2_deploy_contracts invalid or does not take any parameters at Object.run() and i don't know how to resolve it.

  • 1
    Remove build/ directory and try again.
    – Ismael
    Aug 4, 2019 at 15:14
  • It's giving the same error. First time when i migrated it gives no error. But now it's giving that error. Even i created a new pet-shop box and created the new contract and migration file in it Aug 4, 2019 at 15:26
  • But your comment is helpful in many other things Aug 5, 2019 at 9:30

1 Answer 1


I was making a mistake in 2_deploy_contracts1.js file. There was typo instead of module.export I need to write module.exports. So the new 2_deploy_contracts1.js file will be;

var Election1=artifacts.require("election.sol");

Also, I was using the following command to migrate again;

truffle migrate

Instead, I should use the following command if I am migrating again;

truffle migrate --reset

We use this command because we already migrated our smart contracts in the build folder. This command will remove all previously migrated files in the build folder and add new migrated files of smart contracts.

  • For me changing the initial migration to .export broke it too not just my deploy...so both files I have use module.exports but I used truffle migrate --reset and for some reason my second deploy file also worked, while the first time it didn't...
    – iBobb
    Dec 22, 2020 at 21:15

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.