Truffle – Solving Error: ‘Cannot Find Module ‘truffle-expect” During Truffle Migration

migrationsoliditytruffle

I'm following a solidity tutorial right now and I'm currently encountering an error when I run truffle migrate. Also, testrpc is running in another terminal tab, so this issue is unrelated to the others on here.

I run truffle init and then add my HelloWorld.sol smart contract to the contracts folder.

pragma solidity ^0.4.11;

contract HelloWorld {
    uint public balance;

    function HelloWorld(){
        balance = 1000;
    }
}

I then run truffle compile and everything works fine

Compiling ./contracts/ConvertLib.sol... 

Compiling ./contracts/HelloWorld.sol... 

Compiling ./contracts/MetaCoin.sol...

Compiling ./contracts/Migrations.sol... 

Writing artifacts to ./build/contracts

I then added the following to my 2_deploy_contracts.js migration file

var HelloWorld = artifacts.require("./HelloWorld.sol");

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

However when I run truffle migrate I receive the following error:

Error: Cannot find module 'truffle-expect'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:85773:14)
    at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:21:30)
    at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:59914:15)
    at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:21:30)
    at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:201851:15)
    at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:21:30)

I've tried npm installing truffle-expect but that doesn't seem to work either… Any thoughts?

Best Answer

1) Run the following command:

npm install -g truffle-expect truffle-config web3

2) Run testrpc in another shell instance

3) Run truffle migrate in your truffle project directory

Related Topic