What causes problem "Source '@openzeppelin/contracts/access/Ownable.sol' not found: File import callback not supported"?

Hi, I'm following the Developing Smart Contracts "Learn" tutorial, using VSC, and all works fine but I can't seem to resolve a "problem" reported by VSC in connection with a line of code that imports "@openzeppelin/contracts/access/Ownable.sol".

VSC identifies the problem as "Source '@openzeppelin/contracts/access/Ownable.sol' not found: File import callback not supported".

Does anyone know why I get this "problem" and how to resolve it? Those @openzeppelin/contracts/access .sol files are all in my Learn directory, so why is VSC reporting otherwise?

I'm using Truffle.

I've already tried switching the default workspace compiler and modifying the package.json file in the juanblanco.solidity extension but neither change resolves anything.

So you confirm to have installed the modules using npm?

I'm afraid I don't understand your question. Do you mean, did I "npm install @openzeppelin/contracts"? If so, then yes.

But if you mean something else, then please let me know.

Hi, welcome to the community! :wave:

If you have installed the dependency by npm install @openzeppelin/contracts, then check if this file does exist in node_modules/@openzeppelin/contracts/access/Ownable.sol, and then try to compile your contract in the terminal. If all pass, maybe there is something wrong with the VSC config rather than the project.

Yes, no problem compiling. See attached jpg.

Maybe it's an issue with the Juan Blanco extension?

Stupid quesiton but trust me, it worked to me. Did you try to close and reopen the project?

1 Like

Well what do you know. That worked!!

Thank you, Freezy!

8 posts were split to a new topic: Verify contracts but got error: File import callback not supported