when execute "truffle migrate --network dev"
get this:
Could not find artifacts for ./Migrations.sol from any sources
truffle.js
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
contracts_build_directory: "./build",
networks: {
dev: {
host: "localhost",
port: 9545,
network_id: "*",
}
}
};
Using network 'dev'.
Network up to date.
Using network 'dev'.
Running migration: 1_initial_migration.js
/usr/local/nodejs/lib/node_modules/truffle/build/cli.bundled.js:63556
throw new Error("Could not find artifacts for " + import_path + " from any sources");
^
Error: Could not find artifacts for ./Migrations.sol from any sources
at Resolver.require (/usr/local/nodejs/lib/node_modules/truffle/build/cli.bundled.js:63556:9)
at Object.require (/usr/local/nodejs/lib/node_modules/truffle/build/cli.bundled.js:176187:36)
at ResolverIntercept.require (/usr/local/nodejs/lib/node_modules/truffle/build/cli.bundled.js:324348:32)
at /home/leo/Documents/src_codes/dapp/demo/migrations/1_initial_migration.js:1:28
at ContextifyScript.Script.runInContext (vm.js:59:29)
at ContextifyScript.Script.runInNewContext (vm.js:65:15)
at /usr/local/nodejs/lib/node_modules/truffle/build/cli.bundled.js:203486:14
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
if i delete the "2_deploy_contracts.js" and compile and migrate again, it will be ok.
I had similar problem. Solved it by editing 2_deploy_contracts.js to require and deploy the exact contracts I had written.
It may be related to this issue 552
Make sure you named your test as Test + contract name
So if you have a contracts/SECToken.sol
Make sure you test named tests/TestSECToken.sol
and I guess you have name your contract SECToken too
I got the same problem just now, but I solved it in this way.
After your compilation, go to your_folder_location\build\contracts folder.
Then you will see a JSON file which not related to your contract file.
Just rename that JSON file same as your contract file. ( most probably that JSON file related your folder name )
But after that you can see the renamed file as well as the original file too, both files in same location. Don't worry.
That's it.
Thanks for raising this issue @leochan007!
We've finally merged a fix for this into truffle@next via #1331.
I got the same problem just now, but I solved it in this way.
* After your compilation, go to `your_folder_location\build\contracts` folder. * Then you will see a JSON file which not related to your contract file. * Just rename that JSON file same as your contract file. ( most probably that JSON file related your folder name ) * But after that you can see the renamed file as well as the original file too, both files in same location. Don't worry.That's it.
I had a similar problem and I looked into it I got to know that truffle compile compiles the .sol file and generate new JSON file in build folder ./build/contracts/<name_of_contract_in_.sol_file>.json and this JSON file has the name of the contract not the name of .sol file.
Example
I create a test.sol file.
pragma solidity ^0.5.0;
contract MyContract {
uint id;
function set(uint _id) public {
id = _id;
}
}
and now if I truffle compile it I will have ./build/contracts/MyContract.json
and that was the problem for me all along was in 2_deploy_contracts.js file I was doing require the name of the .sol file say it test.sol for the sake of the example here but I had the same name for both contract and filename of .sol file but after looking into it I got to know that my contract name had a one extra letter it was misspelled and that's why I got the error.
so by having same name for contract and its filename solved the problem for me.
I got the same problem just now, but I solved it in this way.
* After your compilation, go to `your_folder_location\build\contracts` folder. * Then you will see a JSON file which not related to your contract file. * Just rename that JSON file same as your contract file. ( most probably that JSON file related your folder name ) * But after that you can see the renamed file as well as the original file too, both files in same location. Don't worry.That's it.
Worked.
To avoid this issue, make sure your contract's and the contract file has the same name:
ie:
"pragma solidity 0.5.12;
contract Token20 {
...
"
in file named Token20.sol
Simply turn on 'Auto Save' on your VS Code. That is the issue . Solved after that.
Most helpful comment
I got the same problem just now, but I solved it in this way.
After your compilation, go to
your_folder_location\build\contractsfolder.Then you will see a JSON file which not related to your contract file.
Just rename that JSON file same as your contract file. ( most probably that JSON file related your folder name )
But after that you can see the renamed file as well as the original file too, both files in same location. Don't worry.
That's it.