Error: Could not find artifacts for " + import_path + " from any sources
See original GitHub issue- I’ve asked for help in the Truffle Gitter before filing this issue.
Issue
truffle(develop)> migrate --reset Compiling .\contracts\MetaCoin.sol… Writing artifacts to .\build\contracts
Using network ‘develop’.
Running migration: 1_initial_migration.js Replacing Migrations… … 0xbe08a360a53514f1751645230046ad03034f2ce3fc6ae2591ecfd34069c67e6a Migrations: 0x8cdaf0cd259887258bc13a92c0a6da92698644c0 Saving successful migration to network… … 0xd7bc86d31bee32fa3988f1c1eabce403a1b5d570340a3a9cdba53a472ee8c956 Saving artifacts… Running migration: 2_deploy_contracts.js C:\Users\labo\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:66536 throw new Error(“Could not find artifacts for " + import_path + " from any sources”); ^
Error: Could not find artifacts for ./MetaCoin.sol from any sources at Resolver.require (C:\Users\labo\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:66536:9) at Object.require (C:\Users\labo\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:77630:36) at ResolverIntercept.require (C:\Users\labo\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:239478:32)
at C:\Windows\system32\metacoin\migrations\2_deploy_contracts.js:2:26
at Script.runInContext (vm.js:74:29)
at Script.runInNewContext (vm.js:80:15)
at C:\Users\labo\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:125917:14
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:532:3)
Environment
-
Operating System: Windows
-
Truffle version (
truffle version
): truffle v 4.1.3 -
node version (
node --version
):v9.9.0 -
npm version (
npm --version
): v 5.8.0
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (3 by maintainers)
Make sure you have the Migrations.sol and that the name of the contract is the same as the name of the file, that solved the issue for me.
I was having the same issue and it came down to the
MyContract.sol
file being in the main project directory instead of the../contracts/
directory. Also ensure that you have a constructor in your contract that initializes the code you’re trying to run.As @pianchemist said,
truffle init
turns the folder in which you run the command into the staging directory for your project and sets up standard default files and structure. The creation of files after this and placing them in the correct directories are up to you. For simple projects, having your contract within thecontracts
directory is as complex as it needs to be. For larger projects, it works like any other programming structure: you may have a folder that contains library code, or a hierarchy of contracts depending on the complexity of your project.Regardless of size and complexity, ensure that your
config
is pointing to the correct locations using the staging directory as the root of the project. Ensure that anyimport
statements also point to the correct location.