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.


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.

| improve this answer | |

Just for reference, as of Truffle v5, truffle-config.js is now the default (and only file that is created) when initializing a new project. Documentation is available here.

| improve this answer | |
  • Adding a reference link and more explanation can improve your answer – Aniket Nov 21 '18 at 4:59

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.
| improve this answer | |
  • 1
    default configuration file name - which one of them is that? – goodvibration Jan 31 '18 at 18:06
  • @goodvibration truffle.js is default. – Roman Frolov Jan 31 '18 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 '18 at 18:14
  • Be advised, there is no "default" configuration name, both perform the same function and it is not a cause for concern. – Vignesh Karthikeyan Apr 30 '18 at 21:32


and do add the following to it

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*" // Match any network id
| improve this answer | |

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.

| improve this answer | |
  • truffle-config.js works for me. Since the infromation dropped down an useful answer for it "- is properly configured in your Truffle configuration file (truffle-config.js)". I'm using Linux – Ender Feb 20 '19 at 3:48

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.