1

I'm following the steps of this tutorial. I created a simple contract, TodoList.sol

pragma solidity ^0.5.0;

contract TodoList {
    uint public taskCount = 0;
}

Then I run truffle compile and get this error message

Error: Could not find .../todolist/contracts/TodoList.sol from any sources
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-resolver/index.js:76:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/async/internal/onlyOnce.js:12:1
    at next (/usr/local/lib/node_modules/truffle/build/webpack:/~/async/whilst.js:68:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-resolver/index.js:64:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-resolver/fs.js:85:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/async/internal/once.js:12:1
    at replenish (/usr/local/lib/node_modules/truffle/build/webpack:/~/async/internal/eachOfLimit.js:61:1)
    at iterateeCallback (/usr/local/lib/node_modules/truffle/build/webpack:/~/async/internal/eachOfLimit.js:50:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/async/internal/onlyOnce.js:12:1
    at ReadFileContext.callback (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-resolver/fs.js:81:1)
    at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:242:13)
Truffle v5.0.2 (core: 5.0.2)
Node v11.12.0

The file is there. If I remove that file, truffle compiles the Migrations.sol automatically generated by truffle init without errors.

When I edit TodoList.sol with VSCode and try to compile it with the Solidity plugin, it doesn't complain, but it doesn't generate any output in the build folder.

2 Answers 2

3

The problem was I edited the file in VSCode, but autosave was turned off. So this is the error message you get if you have an empty file in the contracts directory.

0

Had the same problem and as suggested above, i just went into sublime (source code editor) and saved the work and then "sudo truffle compile" worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.