openmobilehub / react-native-omh-auth

https://openmobilehub.github.io/react-native-omh-auth/
Apache License 2.0
8 stars 2 forks source link

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

Open dzuluaga opened 5 months ago

dzuluaga commented 5 months ago

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.

adamTrz commented 1 month ago

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