Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.3K
Views
Can't import openzeppelin node_modules: File import callback not supported

Whenever I try to compile my solidity contract, the error ParserError: Source \"@OpenZeppelin/contracts/math/SafeMath.sol\" not found: File import callback not supported gets thrown.

pragma solidity ^0.7.0;

import "@OpenZeppelin/contracts/token/ERC20/ERC20.sol";
import "@OpenZeppelin/contracts/math/SafeMath.sol";

Any ideas what could be causing this?

over 4 years ago · Santiago Trujillo
6 answers
Answer question

0

I have the same problem right now. I'm using truffle+node and I fixed it modifying the import path to a relative path, for example,

pragma solidity ^0.7.0;

import "../node_modules/OpenZeppelin/contracts/token/ERC20/ERC20.sol";
import "../node_modules/OpenZeppelin/contracts/math/SafeMath.sol";

I'm not 100% sure why this happen but I hope I helped you.

over 4 years ago · Santiago Trujillo Report

0

For some environments, SafeMath has a different path

import "@openzeppelin/contracts/utils/math/SafeMath.sol";
over 4 years ago · Santiago Trujillo Report

0

actualy the problem is solidity compiler is stupid and doesn't automatically follow path, you have to specify all allowed path manually (https://docs.soliditylang.org/en/latest/using-the-compiler.html), every each one of them and completely to the file(cannot give juste the higher level folder) use npx hardat compile if you can it's better

over 4 years ago · Santiago Trujillo Report

0

After installing OpenZeppelin close your IDE and re-open it.

over 4 years ago · Santiago Trujillo Report

0

Make sure you opened VS Code in the root directory of the project.

In my case, this is how my VS Code directory looked like when I get that same error.

projects
 |___MyContract
   |__contracts
     |__Contract.sol

Reopening VS Code in the MyContract directory fixes it.

MyContract
 |__contracts
   |__Contract.sol
over 4 years ago · Santiago Trujillo Report

0

what worked for me; (I am using Windows10 and visual studio code) -click on the extensions icon -search for the solidity extension -select the uninstall button and click on the drop down arrow -select install another version -select version 0.0.135 -After the installation, click on "Reload required"

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!