Learn guides: Import not working on Windows

I just completed the whole documentation for OpenZeppelin and everything was working fine except the import command.

I created a folder in the folder Contracts and placed Auth.sol in there.

Paths:
[myContract\contracts\Box.sol]
[myContract\contracts\access-control\Auth.sol]

In Box.sol i placed following line right before opening contract Box{}

import "./access-control/Auth.sol";

Then i want to compile with

npx oz compile

and get the following error:

× Compiling contracts with solc 0.7.0 (commit.9e61f22b)
Compilation errors:
contracts\Box.sol:4:1: ParserError: Source "access-control/Auth.sol" not found: File import callback not supported
import "./access-control/Auth.sol";
^-------------------------^

When i try

import "openzeppelin-solidity/contracts/access-control/Auth.sol";

I get:

Could not find openzeppelin-solidity/contracts/access-control/Auth.sol imported from C:\Users\R...\Desktop\dev\myContract\contracts\Box.sol
× Compiling contracts with solc 0.7.0 (commit.9e61f92b)
Compilation errors:
contracts\Box.sol:4:1: ParserError: Source "openzeppelin-solidity/contracts/access-control/Auth.sol" not found: File import callback not supported
import "openzeppelin-solidity/contracts/access-control/Auth.sol";
^-------------------------------------------------------^

I found out i cant even set something like: (which gives me same error)

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

I tried several things like changin to an absoluth path or do it without dot (.) but nothing worked for me. Could anyone help me here? I followed the Docs from A-Z and everything worked except this…

1 Like

Hi @wekael12,

I’m sorry that you are having this issue.

If you are using Windows, I recommend using Windows Subsystem for Linux. I use WSL2. There is an open issue on relative imports with the OpenZeppelin CLI: https://github.com/OpenZeppelin/openzeppelin-sdk/issues/1558


With regards Auth.sol, this is an example in the documentation showing how to import contracts. There isn’t an Auth.sol in OpenZeppelin Contracts. For the available Access control please see the documentation:
https://docs.openzeppelin.com/contracts/3.x/access-control