'Visual Code Studio, File Import Callback not Supported - File Source not Found

While trying to troubleshoot another issue with my project, I must've broken something along the way, but I have no idea how to fix this.

These are my import statements for the project:

pragma solidity >=0.6.6;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@chainlink/contracts/src/v0.6/VRFConsumerBase.sol";

And this is my brownie-config.yaml

depencencies:
  - OpenZeppelin/[email protected]
  - smartcontractkit/[email protected]
compiler:
  solc:
    remappings: 
      - '@openzeppelin=OpenZeppelin/[email protected]'
      - '@chainlink=smartcontractkit/[email protected]'

But despite all this working until yesterday, trying to compile only gives me these errors:

PS C:\Users\XXX\Desktop\Project> brownie compile
INFO: Could not find files for the given pattern(s).
Brownie v1.16.4 - Python development framework for Ethereum

New compatible solc version available: 0.6.6
Compiling contracts...
  Solc version: 0.6.6
  Optimizer: Enabled  Runs: 200
  EVM Version: Istanbul
CompilerError: solc returned the following errors:

contracts/AdvancedCollectible.sol:3:1: ParserError: Source "OpenZeppelin/[email protected]/contracts/token/ERC721/ERC721.sol" not found: File not found.
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
^-------------------------------------------------------^

contracts/AdvancedCollectible.sol:4:1: ParserError: Source "smartcontractkit/[email protected]/contracts/src/v0.6/VRFConsumerBase.sol" not found: File not found.
import "@chainlink/contracts/src/v0.6/VRFConsumerBase.sol";
^---------------------------------------------------------^

How do I solve this? I've seen some answers to similar issues referencing node.js or local copies of the stuff I'm trying to import, but isn't this command supposed to pull stuff off github? Why is it failing to do so out of nowhere?



Solution 1:[1]

Install Openzeppelin at the root of your folder by using npm

npm i @openzeppelin/contracts

same thing for Chainlink

Solution 2:[2]

This is because the solidity extension is looking in the wrong directory. Below step fixed the issue for me -

Change the settings in Solidity extension in VSCode.

The default settings include: "solidity.packageDefaultDependenciesContractsDirectory": "contracts" Users need to change the setting from contracts to an empty string. "solidity.packageDefaultDependenciesContractsDirectory": ""

enter image description here

Source - https://github.com/juanfranblanco/vscode-solidity/issues/178

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BlockChain Learner
Solution 2 Ved Prakash