You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide a reliable way to find the entrypoint path or URL #51840
This solves the same problem as require.main.filename did in a CommonJS-only world: finding the entrypoint script for the Node.js process. This is most commonly used to determine the whether the current file is the entrypoint, but is also useful for various other sorts of introspection about the running Node.js environment. My specific use-case is finding a sensible default base URL to use to replicate Node.js's package resolution algorithm.
What is the feature you are proposing to solve the problem?
I suggest something like process.cliEntrypoint or process.cliMainUrl. I think it's important that any solution be usable regardless of whether the current module is CJS or ESM.
What alternatives have you considered?
require.main.filename provides this information but it doesn't work outside of CJS files, nor does it work if the entrypoint itself is ESM.
process.argv[1]sometimes provides this information, but it has a number of problems:
If the Node.js CLI is run without a file extension, like node myapp instead of node myapp.js, process.argv[1] won't have an extension either.
If the entrypoint is a symlink, process.argv[1] will point to the symlink instead of the physical JS file. This differs from __filename, which means it also differs from the logic used by require(). Note that npm execalways creates a symlink when running executables.
process.argv is mutable, so it's possible for unrelated code to modify it in such a way that it's no longer usable to find the entrypoint.
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the
never-staleIssues and PRs exempt from automated stale handling.
label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the
never-staleIssues and PRs exempt from automated stale handling.
label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the
never-staleIssues and PRs exempt from automated stale handling.
label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
@jsumners-nr Adding a new feature to something as complex as NodeJS is hardly a trivial undertaking. That's the sort of thing one would think a core maintainer would pick up, or at least weigh in on. The request itself also seems completely reasonable, I'm here because I was looking for the same thing.
Directly from the document the bot keeps linking (emphasis added):
At the same time, the project is volunteer run and does not have the ability to direct resources toward specific work. The features which are implemented are those for which volunteers are individually motivated to work on. The best way to ensure a feature gets implemented is to create a PR to add it. The project strives to support people who do that.
I am participating in the project in a few ways, yes. I started watching this issue because I think it is an interesting one. After several "bump" posts, it became clear the path that needs to happen for this to move forward and so I suggested that path.
FWIW, I opened an issue a little while ago inquiring about the NodeJS project adopting some sort of feature bounty program, since I was interested in advancing certain issues / features personally (this one is on the list, just not at the top).
There are some TSC follow up issues to review as well were more discussions have been happening
Activity
github-actions commentedon Aug 21, 2024
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the never-staleIssues and PRs exempt from automated stale handling.
label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
nex3 commentedon Aug 21, 2024
Please don't close this! It would still be very useful!
avivkeller commentedon Aug 22, 2024
@nodejs/loaders
github-actions commentedon Feb 19, 2025
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the never-staleIssues and PRs exempt from automated stale handling.
label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
nex3 commentedon Feb 19, 2025
Again, this would still be extremely useful.
github-actions commentedon Aug 19, 2025
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the never-staleIssues and PRs exempt from automated stale handling.
label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
3 remaining items
jsumners-nr commentedon Aug 21, 2025
I don't think anyone is going to pick this up. It will advance quicker if you supply a PR.
nex3 commentedon Aug 22, 2025
I have my own open source project to run, I'm afraid
jsumners-nr commentedon Aug 26, 2025
I do not believe I suggested you take over running the Node.js project.
shukriadams commentedon Aug 26, 2025
@jsumners-nr Adding a new feature to something as complex as NodeJS is hardly a trivial undertaking. That's the sort of thing one would think a core maintainer would pick up, or at least weigh in on. The request itself also seems completely reasonable, I'm here because I was looking for the same thing.
jsumners-nr commentedon Aug 26, 2025
Directly from the document the bot keeps linking (emphasis added):
avivkeller commentedon Aug 26, 2025
Yes, @jsumners-nr is a member of the Node.js project.
jsumners-nr commentedon Aug 26, 2025
I am participating in the project in a few ways, yes. I started watching this issue because I think it is an interesting one. After several "bump" posts, it became clear the path that needs to happen for this to move forward and so I suggested that path.
nex3 commentedon Aug 26, 2025
I do not believe I said you did. Running an open-source project usually precludes spending a bunch of time adding features to upstream dependencies.
thescientist13 commentedon Sep 1, 2025
FWIW, I opened an issue a little while ago inquiring about the NodeJS project adopting some sort of feature bounty program, since I was interested in advancing certain issues / features personally (this one is on the list, just not at the top).
There are some TSC follow up issues to review as well were more discussions have been happening
Reception has been mixed (I guess?), but who knows 🤞
crydafan commentedon Jan 24, 2026
Is this still needed? I'd like to contribute, thank you kindly
mcollina commentedon Jan 24, 2026
Go ahead!
harishn1408 commentedon Apr 30, 2026
harishn1408 commentedon May 6, 2026
avivkeller commentedon Jul 31, 2026
How does http://github.com/nodejs/node/pull/64800/ look?
module: add module.entrypoint