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.
Best Answer
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.