Skip to content

[Bug]: Build failure due to [ERR_UNSUPPORTED_DIR_IMPORT] error #1226

@CharlyM-CP

Description

@CharlyM-CP

Current Behavior

Can't build my NextJS project due to unsupported directory import error. It happens since version 2.1.8 of the package @web3-onboard/react

@web3-onboard/react v2.1.6 is the last version that I can get it to work

Expected Behavior

No response

Steps To Reproduce

  1. In a NextJs v12.1.6 project
  2. Import and use web3-onboard in the project (for example init, or injectedModule)
  3. Run yarn build

What package is effected by this issue?

@web3-onboard/react

Is this a build or a runtime issue?

Build

Package Version

2.1.8 and above

Node Version

18.7.0

What browsers are you seeing the problem on?

No response

Relevant log output

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/Users/charlym/repos/my-project/node_modules/@web3-onboard/react/dist/hooks' is not supported resolving ES modules imported from /Users/charlym/repos/my-project/node_modules/@web3-onboard/react/dist/index.js
    at new NodeError (node:internal/errors:387:5)
    at finalizeResolution (node:internal/modules/esm/resolve:400:17)
    at moduleResolve (node:internal/modules/esm/resolve:965:10)
    at defaultResolve (node:internal/modules/esm/resolve:1173:11)
    at nextResolve (node:internal/modules/esm/loader:173:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:852:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:439:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36) {
  type: 'Error',
  code: 'ERR_UNSUPPORTED_DIR_IMPORT',
  url: 'file:///Users/charlym/repos/my-project/node_modules/@web3-onboard/react/dist/hooks'
}

Anything else?

A similar issue was pointed out here
And resolved here

Sanity Check

  • If this is a build issue, I have included my build config. If this is a runtime issue, I have included reproduction steps and/or a Minimal, Reproducible Example.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions