Truffle migrate command ReferenceError: Migrations not defined?

Viewed 1564

I'm trying to migrate a test smart contract and when I type the command I'm getting a "ReferenceError: Migrations is not defined" NOTE: The error is for my second file, the first one is migrated without any problem. Here's a screenshot of the full error message:

CMD ERROR

Files in use:

files

I'll leave the code of each file below:

Ethswap.sol:

pragma solidity ^0.5.0;

contract EthSwap {
  string public name = "EthSwap Instant Exchange";
}

2_deploy_contracts.js:

const EthSwap = artifacts.require("EthSwap");

module.exports = function(deployer) {
  deployer.deploy(Migrations);
};

1_initial_migration.js:

const Migrations = artifacts.require("Migrations");

module.exports = function(deployer) {
  deployer.deploy(Migrations);
};

I'd deeply appreciate a solution!

2 Answers

In your 2_deploy_contract.js, Migration is not declared.

Instead of

module.exports = function(deployer) {
  deployer.deploy(Migrations);
};

Change it to

module.exports = function(deployer) {
  deployer.deploy(EthSwap);
};

I was getting the error "ReferenceError: deployer is not defined".

It turns out I had a spelling mistake in my code. The spelling of "deployer" at function(deployer) was wrong. After the correction every thing worked out.

Related