'Solidity library @openzeppelin/contracts/access/Ownable.sol is not resolving ownerOnly()

I am trying to switch my contract to use the 'import "@openzeppelin/contracts/access/Ownable.sol”’, but I am getting the following error

contracts/InvoiceTracker.sol:93:9: DeclarationError: Undeclared identifier. ownerOnly()

for this code: function addClient(address _clientID, string memory _name) public ownerOnly() noDupClient(_clientID, _name) {}

I have installed: "@openzeppelin/cli": "^2.8.2", "@openzeppelin/contracts": "^3.1.0", "@openzeppelin/test-helpers": "^0.5.6”

Can you give me a clue as to why this is happening?



Solution 1:[1]

you should call onlyOwner() and not ownerOnly()

Solution 2:[2]

You must Call the onlyOwner() if you are importing the @openzeppelin/contracts/access/Ownable.sol. You can't change onlyOwner() to ownerOnly().

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Emmanuel Collin
Solution 2 Vijay raj panchal