I have a truffle project created with truffle init
.
I ran the npm i @openzeppelin/contracts
command, I can see the contracts in the node_modules
folder.
In my contract I have an import such as:
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
but when I do truffle compile
, I get:
ParserError: Source "@openzeppelin/contracts/token/ERC721/ERC721.sol" not found
--> project:/contracts/BossNFT.sol:4:1:
|
4 | import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; // NFT's standard
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Truffle v5.11.5 (core: 5.11.5)
Node v18.18.0
I tried to close and reopen the project, to import everything locally. I am desperate.
Edit
For the moment the solution has been to move that particular import
under others.
This way:
import "@openzeppelin/contracts/access/Ownable.sol"; // to handle the ownership of the contract
import "@openzeppelin/contracts/utils/Counters.sol"; // to auto-increment the tokenID
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
Instead of this way:
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol"; // to handle the ownership of the contract
import "@openzeppelin/contracts/utils/Counters.sol"; // to auto-increment the tokenID
Any ideas about why?