Resolve node_modules path in compiler
See original GitHub issueThe 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:
- Created 6 years ago
- Reactions:7
- Comments:45 (23 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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 thenode_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 thenode_modules
folder would bring us quite a bit forward towards more secure smart contracts in general.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”.