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.

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

3 Answers 3

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]

3
  • thats not solving the issue
    – cryptoKTM
    Mar 12, 2019 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). Mar 14, 2019 at 18:20
  • i needed to compile the solc file with sudo command and it worked for me
    – cryptoKTM
    Mar 15, 2019 at 7:14
0

try with this command 'sudo truffle compile'

1
  • 1
    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, 2019 at 17:20
0

Sudo is the magic word..solved my issue too

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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