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.

openzeppelin-solidity imports are highlighted red (but compile fine)

See original GitHub issue

I use openzeppelin-solidity package in my project (installed with npm install --save openzeppelin-solidity), and my smart contract file has this line:

import "openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol";

VS Code highlights import in red with the error Source "openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol" not found

Everything compiles and works fine, it’s just annoying to see an error. Anything can be done about that?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

22reactions
juanfranblancocommented, May 18, 2018

For that scenario you need your user settings as following:

    "solidity.packageDefaultDependenciesContractsDirectory": "",
    "solidity.packageDefaultDependenciesDirectory": "node_modules",
8reactions
kigawascommented, May 25, 2018

@djneely @aleybovich

Say your repo structure looks like this (openzeppelin-solidity is in node_modules):

.
├── .git
├── .gitignore
├── README.md
└── src
    ├── contracts
    │   └── Hello.sol
    ├── node_modules
    │   └── openzeppelin-solidity
    ├── package-lock.json
    └── package.json

5 directories, 5 files

If you open vscode at the root level, you should config like:


    "solidity.packageDefaultDependenciesContractsDirectory": "",
    "solidity.packageDefaultDependenciesDirectory": "src/node_modules",

Read more comments on GitHub >

github_iconTop Results From Across the Web

VScode Solidity extension - not finding openzepplin imports
Even though vscode shows red squigglies I can compile successfully via hardhat compile. If I change the path to. import "../node_modules/@ ...
Read more >
Trouble importing OpenZeppelin Contracts into VS Code
Long story short I'm new and I've been developing a project that compiles fine before I add an import statement to one of...
Read more >
How to Import Solidity Files in VS Code with IDE Support
I coped with the red screaming squiggly lines. I learned to ignore and . ... import "openzeppelin-solidity/contracts/math/SafeMath.sol";.
Read more >
Editor and error list reports non-existent errors about missing ...
I have double checked the the references are added, and the code compiles and runs just fine, but a bunch of stuff gets...
Read more >
Sudden errors on Visual Studio Code Imports - Ionic Framework
So previously an import such as: import { myService } from "src/app/co… ... work fine - but all my components are now riddled...
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