Skip to content

bug: Hardhat v3 'HHE902: The file is not exported' error #1721

@optifat

Description

@optifat

Describe the bug
Layerzero oft contracts + Hardhat v3 combination throws an error like

Error HHE902: There was an error while resolving the import "@layerzerolabs/oft-evm/contracts/OFTAdapter.sol" from "./contracts/MyOFTAdapter.sol":

The file "contracts/OFTAdapter.sol" is not exported by the package.

I guess the same occurs with the other contracts too, but didn't check that out.

To Reproduce
Steps to reproduce the behavior:

  1. yarn add --dev hardhat @layerzerolabs/oft-evm (I get "hardhat": "^3.0.6")
  2. yarn hardhat init
  3. Add oft adapter contract from layerzero quickstart
  4. yarn hardhat compile

Expected behavior
Successful compilation

Environment (please complete the following information):

  • OS: macOS
  • OS Version: 15.6.1
  • VM: nodejs
  • VM Version: v24.5.0

Additional context
I'm not that familiar with nodejs ecosystem, but I guess the issue is that hardhat v3 now forces(?) ESM usage via "type": "module". While your package.json has exports section, it lacks contracts directory, which seems to me as a reason of compilation error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions