ParserError: Source "@openzeppelin/contracts/access/Ownable.sol" not found: File not found.
See original GitHub issueHi guys, I’m following the OpenZepellin tutorial wich works fine, but when I run the mith analyze
I received that error:
ParserError: Source "@openzeppelin/contracts/access/Ownable.sol" not found: File not found.
Here’s the code snippet of the smart contract:
pragma solidity ^0.8.0;
// Import Ownable from the OpenZeppelin Contracts library
import "@openzeppelin/contracts/access/Ownable.sol";
// Make Box inherit from the Ownable contract
contract Box is Ownable {
uint private value;
// Emitted when the stored value changes
event ValueChanged(uint256 newValue);
...
If a change my code to import the contract as below, it works!
import "../node_modules/@openzeppelin/contracts/access/Ownable.sol";
How can I use the import statement just using @ and not a relative path of the node_modules to the OpenZepellin contracts?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:10
Top Results From Across the Web
Could not find Ownable.sol file @openzeppelin/contracts ...
I went through the node_modules and I could not find the Ownable,sol file in @openzeppelin/contracts/access/Ownable.sol.
Read more >Can not import @openzeppelin/contracts/access/Ownable.sol ...
Go to ERC725 root directory and do npm install because your error shows that openzeppelin files are not found so most probably you...
Read more >ethereum/remix - Gitter
openzeppelin -contracts/contracts/access/Ownable.sol:5:1: ParserError: Source "openzeppelin-contracts/contracts/GSN/Context.sol" not found: File import ...
Read more >“ParserError: Source “openzeppelin/contracts/token/*.sol” not ...
Solution: One of the potential causes for this error could be a missing node_modules folder in the directory which contains the contracts directory....
Read more >Trying to compile contract but getting "ParserError: Source ...
Trying to compile contract but getting "ParserError: Source "@openzeppelin/contracts/token/ERC1155/IERC1155.sol" not found: File not found." Ask ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@idirall22 , you can either use
standard-json
format of solc or you can just add all the imports as code into a single contract.@devScrooge add a json file to remap the path to node_modules folder:
{ "remappings": [ "@openzeppelin/contracts-upgradeable/utils/=../node_modules/@openzeppelin/contracts-upgradeable/utils/" ], "optimizer": { "enabled": true } }
run myth with
--solc-json
option:myth analyze test.sol --solc-json remapping.json