question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ParserError: Source "@openzeppelin/contracts/access/Ownable.sol" not found: File not found.

See original GitHub issue

Hi 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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:10

github_iconTop GitHub Comments

3reactions
norhhcommented, Jul 27, 2021

@idirall22 , you can either use standard-json format of solc or you can just add all the imports as code into a single contract.

2reactions
vvxhidcommented, Sep 9, 2022

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found