-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[Bug]: require.main has invalid value null #15185
Comments
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
This is still happening, including in 30.0.0-alpha.6, although for some reason the console.log message isn't visible anymore. I have updated the test to actually make an assertion. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
1 similar comment
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Version
29.7.0
Steps to reproduce
Expected behavior
When running
node bin/app.js
, it prints "Note that require.main is undefined".Actual behavior
During
npm run test
, it prints "Note that require.main is null".Additional context
According to the nodejs docs,
require.main
is a reference to the entry module, when the entry script is CJS andundefined
otherwise. The valuenull
is not valid forrequire.main
. This confuses some third-party libraries that check for CJS vs ESM withtypeof require.main === 'object'
, (sincetypeof null
is"object"
). One such example is umzug, when it loads migration files.Environment
System: OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm) CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz Binaries: Node: 18.20.4 - /usr/bin/node Yarn: 1.22.22 - /usr/bin/yarn npm: 10.7.0 - /usr/bin/npm pnpm: 8.6.5 - /usr/bin/pnpm npmPackages: jest: ^29.7.0 => 29.7.0
The text was updated successfully, but these errors were encountered: