Could not find artifacts for ./Migrations.sol from any sources
See original GitHub issue- I’ve asked for help in the Truffle Gitter before filing this issue.
Issue
when execute “truffle migrate --network dev” get this: Could not find artifacts for ./Migrations.sol from any sources
Steps to Reproduce
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: "*",
}
}
};
- truffle unbox metacoin
- truffle compile
- truffle migrate --network dev
Expected Behavior
Using network ‘dev’.
Network up to date.
Actual Results
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)
Environment
- Operating System: ubuntu 16.04
- Truffle version: 4.0.3
- Ethereum client: geth
- node version: 8.9.3
- npm version: 5.6.0
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (1 by maintainers)
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