Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dzuluaga opened this issue Jun 12, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@dzuluaga
Copy link
Contributor

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.

@dzuluaga dzuluaga added the bug Something isn't working label Jun 12, 2024
@adamTrz
Copy link
Collaborator

adamTrz commented Oct 23, 2024

I wasn't able to reproduce this error 😞
@dzuluaga could you please check if it still appears for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants