1

I'm trying to develop a simple dapp using ReactJS.I used Charterhouse/truffle-create-react-app box suggested by truffle website. The problem is truffle compile and truffle migrate do not seem to work. All I get is this:

Compiling ./contracts/Migrations.sol...
Compiling ./contracts/SimpleStorage.sol...

No errors but build directory is not created.

I'm using ganache-cli and Metamask. Here's my truffle.js:

 module.exports = {
 networks: {
 development: {
  host: 'localhost',
  port: 8545,
  network_id: '*' // Match any network id
   }
 },
 compilers: {
      solc: '^0.4.24' //added because I have written my own contracts
                      //with this version
   },
   solc: {
     optimizer: {
     enabled: true,
     runs: 200
     }
   }
 }

output of truffle network:

Contracts have not been deployed to any network.

output of truffle version:

Truffle v5.0.0 (core: 5.0.0)
Solidity v0.5.0 (solc-js)
Node v8.10.0

I have also tried truffle compile and truffle migrate with --reset and --all but no differences.

  • Try using truffle migrate --network development. – GrandFleet Jan 4 at 22:19
0

I believe the issue is your truffle.js file. Your version ('^0.4.24') should be defined on a "version" key within the "solc" object. Try this instead:

module.exports = {
  networks: {
    development: {
      host: 'localhost',
      port: 8545,
      network_id: '*' // Match any network id
    }
  },
  compilers: {
    solc: {
      version: '^0.4.24',
      settings: {
        optimizer: {
          enabled: true,
          runs: 200
        }
      }
    }
  }
};

See here for more details on compiler configuration: https://truffleframework.com/docs/truffle/reference/configuration#compiler-configuration]

  • thats not solving the issue – cryptoKTM Mar 12 at 14:23
  • @cryptoKTM what's your issue? My answer seems to have solved Saman's issue (in their case, an error in their truffle.js). – Sam Richards Mar 14 at 18:20
  • i needed to compile the solc file with sudo command and it worked for me – cryptoKTM Mar 15 at 7:14
0

try with this command 'sudo truffle compile'

New contributor
Arzon Barua is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • If you have to use sudo then it is likely a problem with permissions. Using sudo is a security problem it is better to fix your permissions issues. It is better to use something like nvm so you can run node without root permissions. – Ismael Sep 13 at 17:20

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.