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:
Clone the repository.
Attempt to push changes using git push.
Expected Behavior:
The push operation should complete without any errors.
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 thatrequire()
is not supported for ES Modules. The issue arises when theimport-local/index.js
file tries to requirepkg-dir
.Error Message:
Steps to Reproduce:
git push
.Expected Behavior: The push operation should complete without any errors.