Skip to content

Error [ERR_REQUIRE_ESM]: require() of ES Module from import-local not supported #77

Description

@dzuluaga

When attempting to push code to the repository, I encountered an error due to the pkg-dir module being an ES Module. The error message indicates that require() is not supported for ES Modules. The issue arises when the import-local/index.js file tries to require pkg-dir.

Error Message:

git push
╭─────────────────────────────────────╮
│ 🥊 lefthook v1.6.15  hook: pre-push │
╰─────────────────────────────────────╯
┃  unit-test ❯

/Users/diegozuluaga/tools/git/react-native-omh-auth/node_modules/import-local/index.js:5
const pkgDir = require('pkg-dir');
               ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/diegozuluaga/tools/git/react-native-omh-auth/node_modules/pkg-dir/index.js from /Users/diegozuluaga/tools/git/react-native-omh-auth/node_modules/import-local/index.js not supported.
Instead change the require of /Users/diegozuluaga/tools/git/react-native-omh-auth/node_modules/pkg-dir/index.js in /Users/diegozuluaga/tools/git/react-native-omh-auth/node_modules/import-local/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/diegozuluaga/tools/git-react-native-omh-auth/node_modules/import-local/index.js:5:16)
    at Object.<anonymous> (/Users/diegozuluaga/tools/git-react-native-omh-auth/node_modules/jest/bin/jest.js:9:21) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v18.17.1

Steps to Reproduce:

  1. Clone the repository.
  2. Attempt to push changes using git push.

Expected Behavior:
The push operation should complete without any errors.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions