1

I'm using macOS High Sierra. I installed truffle and ganache-cli as below

npm install -g truffle
npm install -g ganache-cli

Then I created a directory and cd to it to run the test

mkdir ethereumTest
cd ethereumTest

I initiate the truffle and compile it

truffle init
truffle compile

Since I'm on Mac, I changed the truffle.js file as below

module.exports = {
   network: {
     development: {
        host: "127.0.0.1",
        port: 8545,
        network_id: "*"
    }
  }
};

I opened another terminal and ran ganache-cli ganache-cli

But when I tried to migrate to the network in the previous terminal, it gives error

truffle migrate

It gives

Unknown network "[object Object]". See your Truffle configuration file for available networks.

truffle network --network development

It gives

Unknown network "development". See your Truffle configuration file for available networks.

I also tried the following

  • remove truffle-config.js
  • change truffle-config.js as the same as truffle.js
  • In the truffle.js file, change host to localhost

But none of them works, any other suggestion?

  • 1
    truffle network??? I think what you mean is truffle migrate. – goodvibration Jul 21 '18 at 16:12
  • @goodvigration, oh, yeah, thanks. Already edited it. – Tracy Yang Jul 21 '18 at 16:31
  • truffle-config.js and truffle.js are the same, you only need one of them (on Windows, calling truffle might lead to a "collision" with truffle.js, so better use truffle-config.js, but you're not even using Windows). – goodvibration Jul 21 '18 at 18:39
  • did you launch ganache-cli before migrating? also, what do you get with truffle develop ? – Nikita Fuchs Jul 21 '18 at 18:58
  • 1
    @NikitaFuchs, I did launch ganache-cli before migrating. And interesting, truffle develop gives Truffle Develop started at http://127.0.0.1:9545/, but in the ganache-cli, the port is indeed 8545 instead of 9545 – Tracy Yang Jul 21 '18 at 19:19
1

Change your "network" to "networks" in the truffle.js configuration file. Refer https://truffleframework.com/docs/truffle/reference/configuration for example configurations.

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.