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.

Resolve node_modules path in compiler

See original GitHub issue

The compiler can’t resolve the node_modules path, e.g. as follows:

import "node_modules/zeppelin-solidity/contracts/math/SafeMath.sol";

I have to use the complete relative path to modules, and the vscode-solidity compiler will work:

import "../../node_modules/zeppelin-solidity/contracts/math/SafeMath.sol";

Did i miss something in configuration, or will this be fixed in an future version?

Best regards Patrice

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:7
  • Comments:45 (23 by maintainers)

github_iconTop GitHub Comments

12reactions
SCBuergelcommented, Sep 6, 2017

@juanfranblanco both import "../../node_modules..... as well as copying or sym-linking seems more like a hack. I see many projects relying on truffle. Supporting these projects in an IDE-agnostic fashion would really help here. Therefore I’d suggest to be compatible with truffle and thus resolve everything in the node_modules folder by default. The bigger picture is that I’m trying to limit the copy-pasting of Zeppelin libraries - and encourage others to follow good practices as well. That requires tools to be sufficiently flexible hence including the node_modules folder would bring us quite a bit forward towards more secure smart contracts in general.

9reactions
ImmuneGitcommented, Mar 18, 2018

I see that the problem is still presents. VSCode can’t find a path to zeppelin’s contracts when I write like this: import “zeppelin-solidity/contracts/ownership/Ownable.sol”. screen shot 2018-03-18 at 12 26 45 pm

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import ... A node_modules folder can be on the same...
Read more >
tsc is trying to resolve relative path modules in the wrong folder
You can resolve this by using the "paths" key in the "compilerOptions" in your tsconfig.json . Something like this:
Read more >
Resolve | webpack
A relative path will be scanned similarly to how Node scans for node_modules , by looking through the current directory as well as...
Read more >
How to use the path.resolve function in path - Snyk
To help you get started, we've selected a few path.resolve examples, based on popular ways it is used in public projects.
Read more >
Common TypeScript module problems and how to solve them
Solution 1: Locate the correct directory ; "compilerOptions": ; "baseUrl": ; ".", ; "paths": ; "express": ...
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