-1

I have successfully installed openzeppelin/contracts, but I am unable to import it. It shows me an error which is

Source "@openzeppelin/contracts/access/Ownable.sol" not found: File import callback not supported

Does anyone have any idea?

Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 20 '22 at 21:48

3 Answers3

0

Please Check the @openzeppelin/contracts is installed in Correct Directory..

Also What npm version of @openzeppelin/contracts you have installed ? The positon of OpenZepplin Contracts is changed after version 4..

Refer..

https://forum.openzeppelin.com/t/openzeppelin-contracts-ownership-ownable-sol-not-found/16229/3

https://forum.openzeppelin.com/t/error-importing-openzeppelin-contracts-in-vscode/6971/11

sms
  • 1,380
  • 1
  • 3
  • 5
0

Simplest hack:

CTRL + SHIFT + P -> Reload Window

Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 19 '23 at 21:02
0

Your question is not very clear but I will try and provide an answer in the context in which I understood it as I also face similar issue.

"@openzeppelin/contracts/access/Ownable.sol"

The import form above works well for solidity version 0.6.x but if you are using solidity version ^0.8.x it doesn't work.

This is how I resolved the issue. First install openzeppelin with the npm installer:

npm i @openzeppelin/contracts

The command above will install the current version of openzeppelin. At the time of writing this, the current version is 4.x. After the install is successful import openzeppelin this way:

import "../node_modules/@openzeppelin/contracts/access/Ownable.sol";

That is the directory where npm installed it.

I hope this helps someone.

John
  • 313
  • 3
  • 8