I can't use ERC721URIStorage with Ownable

When I use ERC721URIStorage with Ownable, all the codes are underlined in red. Is it a version issue for Solidity? I tried changing it to version 0.8.4 as well, but I get the same error. (I used a translator. Thank you.)

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

//import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol";
//import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";

contract MyToken is ERC721URIStorage, Ownable
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIdCounter;

    event TokenMint(address _to, uint256 _tokenId);

    constructor() ERC721("HuskyArt", "HSA") {}

    function safeMint(address _to, string memory _uri) public onlyOwner
        uint256 tokenId = _tokenIdCounter.current();
        _mint(_to, tokenId);
        _setTokenURI(tokenId, _uri);
        emit TokenMint(_to, tokenId);

    function _burn(uint256 tokenId) virtual internal override(ERC721, ERC721URIStorage)

    function tokenURI(uint256 tokenId)
        override(ERC721, ERC721URIStorage)
        returns(string memory)
        return super.tokenURI(tokenId);

Hello @cosm0snnt

Having the code underlined in red is something your IDE does. It really depends how things are configured. There may not be an error at all.

Does this come with some message secribing what is wrong? Have you tried compiling?

The first thing I notice is that you use the "Counters.sol" library, which was removed in OZ 5.0. Which version of the library are you using?

You should probably start with code produced by the wizard instead of whatever you are using as a reference.

"Counter.sol" library was removed? I didn't know about that. I'm currently a college student, and my professor explained this code based on pragma solidity ^0.8.4;. (We use remix.ethereum.org)

At first, I removed "Counters.sol" library. And then everything just seemed to be fine.

Next, I changed compiler to 0.8.4+commit.c7e474f2(include nightly builds. But honestly, I don't know what 'nightly builds' is).

And now, I think I broke everything. Should I start all over again? (It's okay to remove everything and just re-start. Thanks.)

Yes, pretty much in my opinion. These looks like a dependency conflict as well, if you've kept the project for long in Remix's storage, new imported contracts might come from a newer version (could have breaking changes between our 4.x and 5.x).

Starting the project all over (or at least the imports) should do the job. However, you might require to fix those breaking changes. You can see a detailed list of breaking changes in our changelog.

"Counter.sol" library was removed?

Yes, it's also mentioned in the CHANGELOG, though, it's trivial to replace. This is a clear example.

This is my first time using Solidity. I was really confused. Thank you for clear advice!