"Could not find import from any sources" error

Hi guys, I am still getting this error using openzeppelin 3.3.0 library, solidity compiler 0.7.6, and truffle v5.1.60.

I tried to downgrade the truffle to v5.1.59 and v5.1.58 but it did not help. And with the message saying “Error: Could not find \n import from any sources;” I have no idea what is wrong. (It would be great if truffle would improve this error message.)

The only thing I know is that when I remove import from openzeppelin library, the compilation works again.

I installed openzeppelin package through npm locally and my import is as follows:
import “@openzeppelin/contracts/utils/EnumerableSet.sol”

1 Like

Hi @Ivco,

Welcome to the community :wave:

I wasn’t able to reproduce on Windows 10 using a simple contract.
Can you try compiling this contract and share the output so we can see the errors?
What operating system, node and npm version are you using?


// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

import "@openzeppelin/contracts/utils/EnumerableSet.sol";

contract MyContract {


Truffle Compile

> npx truffle compile

Compiling your contracts...
√ Fetching solc version list from solc-bin. Attempt #1
√ Downloading compiler. Attempt #1.
> Compiling @openzeppelin/contracts/utils/EnumerableSet.sol
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\MyContract.sol
> Artifacts written to C:\Users\andre\Documents\projects\forum\lvco\build\contracts
> Compiled successfully using:
   - solc: 0.7.6+commit.7338295f.Emscripten.clang

Truffle Version

> npx truffle version
Truffle v5.1.60 (core: 5.1.60)
Solidity - 0.7.6 (solc-js)
Node v10.16.3
Web3.js v1.2.9

Hi @abcoathup, thank you for the reaction. I tried to find the minimal working example, in which, it is easy to see the syntax error I made - missing semicolon in the first import. If I miss the semicolon in the second import, the error message is fine. While these things seem funny in the minimalistic example, if one has multiple imports and hundred lines of code, it is not easy to find the problem and the error message really does not help. However, this is the issue of solidity compiler, not Openzeppelin.

// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

import "@openzeppelin/contracts/utils/EnumerableSet.sol"
import "@openzeppelin/contracts/math/SafeMath.sol";

contract MyContract {

1 Like

Hi @Ivco,

Glad you found the issue. Definitely not obvious given the error message.

I recommend creating an Issue with Truffle to report as a better error message would have saved a huge amount of time.