# Truffle does not add “networks” to build/contracts/contract.json after migration

Problem

Truffle does not add "networks" to build/contracts/contract.json files after migration.

Versions running

• Truffle v4.0.1 (core: 4.0.1)
• Solidity v0.4.18 (solc-js)
• EthereumJS TestRPC v6.0.3 (ganache-core: 2.0.2)
• MacOS High Sierra 10.13.1

1. Downgrading Truffle: I have tried to downgrade from Truffle version 4.0.4 to version 4.0.0 and then to 4.0.1 to test if it has something to do with Truffle version, but unfortunately I get the same problem.

truffle.js file looks like this:

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

1. I also tried to run over port 9545 with $truffle develop, but got the same problem. Error message When I run $ truffle test I get the following error message:

Error: TestContract has not been deployed to detected network (network/artifact mismatch)

What does work

When I run \$ truffle migrate --reset, my build/contracts/Migrations.json file does have the networks specified like:

...
"networks": {
"1516203204392": {
"events": {},
}
},
...

• Can you also add your file(s) from /migrations? – Adam Kipnis Jan 17 '18 at 16:07
• What is in your migrateion folder? Is there 2_deploy_contracts.js or some other code which is running to migrate your contracts to blockchain? – Roman Frolov Jan 18 '18 at 9:46
• @RomanFrolov the 1_initial_migrations.js file, but I found out that I did not deploy my contract in migrations file for some stupid reason. But now I have the following problem.. ethereum.stackexchange.com/questions/36690/… – Robbert Jan 18 '18 at 9:49
• truffle migrate --reset helps me. Just note here so anybody else meet problem can use that :D – hqt May 19 '18 at 13:12

On closer observation, the issue is with 2_deploy_contracts.js. When you are running truffle migrate --reset Keep an eye on the text Saving artifacts... And also take a look at after which contract deployment this appears, and after this is the problem in the migration file.
I had some async/awaits in there and apparently the code executes but writing the artifacts has some time constraints and runs after the third contract deployment therefore only 3 of my contracts had networks populated and rest empty.
• truffle migrate --reset helps me. Just note here so anybody else meet problem can use that :D – hqt May 19 '18 at 13:12