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.

  • truffle.js was used in earlier versions of truffle i.e. 4 and below. Latest version uses truffle-config.js see trufflesuite.com/docs/truffle/reference/… – Ashutosh Singh Oct 30 '20 at 10:52
  • @AshutoshSingh: This question was posted when truffle 4 was the latest version. – goodvibration Oct 30 '20 at 10:55
  • I understand, the reason I added this comment because I just copied an example built with older truffle version, and I saw truffle.js file. So anyone in future having this situation might have this question.... Hence just put it here for reference – Ashutosh Singh Oct 30 '20 at 11:02
  • @AshutoshSingh: OK, thanks. – goodvibration Oct 30 '20 at 11:09

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.


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.

  • 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.
  • 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

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.

  • 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.