I have solidity project with files like

pragma solidity ^0.5.0;

import "openzeppelin-solidity/contracts/ownership/Ownable.sol";

When I try to compile, I get error on not installed library

npx hardhat compile                
Error HH411: The library openzeppelin-solidity, 
imported from contracts/....sol, is not installed. 
Try installing it using npm.

I have tried installing

npm install @openzeppelin/contracts

and v3.1.0 that is proper match for solidity v0.5.0

npm install @openzeppelin/contracts@3.1.0

But get the same error.

So what is this openzeppelin-solidity library, and how to install it?

2 Answers 2


Thanks to @zmy comment, pointing to https://www.npmjs.com/package/openzeppelin-solidity.

2.3.0 is earliest version on npm registry as "@openzeppelin/contracts"
openzeppelin-solidity has older versions

So installation should be like

npm i openzeppelin-solidity@2.2.0   

and version in range 2.1.0-2.5.1 (for solidity v0.5.0)

2.1.0 is first version to target solidity v0.5.0 https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/CHANGELOG.md#210-2019-01-04
3.1.0 is Last openzeppelin-contracts version to work with solidity v0.5.0 https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/CHANGELOG.md#320-2020-09-10
3.0.0 (2020-04-20) AccessControl: new contract for managing permissions in a system, replacement for Ownable.
so Ownable is not available since v3.0.0
Latest is v4.2.0 (2021-06-30), requires solidity 0.8.0 since v4.0

  • Very good. You explained it in great detail👍
    – zmy
    Jul 20, 2021 at 9:26

Your code is wrong. The correct code should look like this.

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

There is no such library openZeppelin-solidity, The correct library is@openZeppelin/contracts


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.