Not found: File import callback not supported import "../utils/Context.sol"

:computer: Environment

  • package.json
"dependencies": {
        "@openzeppelin/contracts": "^3.4.0",
        "@truffle/hdwallet-provider": "1.2.2",
        "ganache-cli": "^6.12.2",
        "mocha": "^8.3.2",
        "solc": "^0.7.6",
        "truffle": "^5.3.4",
        "web3": "^1.3.5"
      }
  • truffle-config.js
    compilers: {
            solc: {
                version: "^0.7.6",
                settings: {optimizer: {enabled: true, runs: 200}}
            }
        }

pragma solidity >0.6.0;

:memo:Details
I compile smart contract local by truffle compile & get this error
not found: File import callback not supported import "../utils/Context.sol"

In smart contract implement ERC721PresetMinterPauserAutoId

Please share your code

// SPDX-License-Identifier: MIT
pragma solidity >0.6.0;

import "@openzeppelin/contracts/presets/ERC721PresetMinterPauserAutoId.sol";

contract MyProfileNFT is ERC721PresetMinterPauserAutoId {
    constructor(
        string memory name,
        string memory symbol,
        string memory baseUri
    )
    public
    ERC721PresetMinterPauserAutoId(
        name,
        symbol,
        baseUri
    )
    {}
}
pragma solidity >0.6.0;

import "@openzeppelin//contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "./MyProfileNFT.sol";

contract MyProfile is Ownable, IERC721Receiver {
...

Full error

@openzeppelin//contracts/access/Ownable.sol:5:1: ParserError: Source "@openzeppelin//contracts/utils/Context.sol" not found: File import callback not supported
import "../utils/Context.sol";
^----------------------------^

I solved my error invalid import other contract path.

thank you.

1 Like

You’re welcome. https://en.wikipedia.org/wiki/Rubber_duck_debugging

1 Like