Truffle configuration file is mentioned in several places on the web (GitHub, truffle package on npm, solidity-coverage package on npm, etc.).

Some refer to it as 'truffle.js, others refer to it as truffle-config.js.

When creating a project with truffle init, both files are created.

Which one of them should I use?

Thank you.

up vote 17 down vote accepted

On windows systems having truffle.js in your main folder may create a conflict when you try to execute truffle.

Windows first try for executables in your current directory, and .js files are considered executables, then when it tries to execute your configuration file it will fail.

To be compatible with windows you can either rename your configuration file to truffle-config.js or execute truffle with truffle.cmd.

If you do not care about windows then you can use truffe.js.

You should use truffle.js


And from this page of Truffle docs my understanding is that:

  • Both files are created on initiation because default configuration file name can cause a conflict with the truffle executable, and so you may not be able to run Truffle commands properly on existing projects.
  • 1
    default configuration file name - which one of them is that? – goodvibration Jan 31 at 18:06
  • @goodvibration truffle.js is default. – Roman Frolov Jan 31 at 18:13
  • "Your configuration file is called truffle.js and is located at the root of your project directory." - First line from the link I provided in the answer. – Roman Frolov Jan 31 at 18:14
  • Be advised, there is no "default" configuration name, both perform the same function and it is not a cause for concern. – Meshugah Apr 30 at 21:32

truffle.js

and do add the following to it

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*" // Match any network id
    }
  }
};

Truffle does not distinguish between truffle.js and truffle-config.js.

So, an easy way to deal with this, as referenced in Mastering Ethereum, is to simply delete this and use truffle-config.js instead.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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