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?

ycenycute
  • 111
  • 3
  • 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. – ycenycute 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 ? – n1cK 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 – ycenycute Jul 21 '18 at 19:19
  • @NikitaFuchs, and I just tried 9545, it does not work either. – ycenycute Jul 21 '18 at 19:20
  • What version of truffle and ganache are you using? Are you in the correct directory when you execute truffle migrate? Keep only one of truffle.js or truffle-config.js not both. – Ismael Jul 24 '18 at 01:59
  • @Ismael, truffle is v.4.1.13, and ganache is Ganache CLI v6.1.6 (ganache-core: 2.1.5). I believe I'm in the correct directory. And I did try remove one of them, but still did not work. – ycenycute Jul 25 '18 at 02:35
  • We are using the same versions and it does work here. What version of node are you using? If you are using node v8 or newer it should work. I'd suggest to report to truffle developers. – Ismael Jul 25 '18 at 13:45

1 Answers1

1

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