@openzeppelin/contracts/ownership/Ownable.sol not found

I am getting a not found error even if I have installed the openzeppelin libraries and imported correctly. Why am I getting this error?
Error HH404: File @openzeppelin/contracts/ownership/Ownable.sol, imported from contracts/PositionManager.sol, not found.

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

import "@openzeppelin/contracts/ownership/Ownable.sol";

I am using Hardhat 2.6.4;
Openzepplin/contracts ^4.3.2
Solidity ^0.8.0

The error message tells you that it cannot find the Ownable file when it is trying to import it so the question is, how do you put an Ownable file on the path that you are trying to import? hint: it has to do with installing the @openzeppelin/contracts package.

1 Like

The correct import statement for OpenZeppelin Contracts 4.x is:

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

The position of the Ownable.sol file has changed to the packages\OpenZeppelin\openzeppelin-contracts@3.4.0\contracts\access and you are probably going with a deprecated version of the doc.