Skip to content

How does require.resolve work? #8526

@ccorcos

Description

@ccorcos

I'd like to submit a PR that resolves the root project's package name so that you can use absolute require paths. However, I'm finding it very hard to figured out how this bit of code works:

https://github.com/nodejs/node/blob/7b73f559029a10474b74a83bfb1117ab512785d4/lib/module.js

Seems like it should be a one-liner somewhere. I just need to add the base project as one of the "paths" to search. Any ideas where that might be?

I'm thinking its in here.

Module._resolveLookupPaths = function(request, parent) {

Something like paths.push(path.dirname(parent.id)).

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.moduleIssues and PRs related to the module subsystem.questionIssues that look for answers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions