Skip to content

Startup time optimization - specifying location of node_modules #25072

@ORESoftware

Description

@ORESoftware

I am guessing that node.js startup could be optimized if we specify the (only) location of node_modules. I believe that the fs gets peppered with stat requests on startup, but if we had something like this:

$ node --nm="./node_modules" dist/main.js

then when non-relative require statements were evaluated, they could jump to the location specified by --nm, this might save hundreds of stat calls on startup?

I would venture to guess that 95% of npm projects only have one relevant node_modules dir, so walking up the filesystem for nested files could be optimized.

I would guess that there may already be some optimization for this in place, where directories are marked as not having a node_modules dir within them on first pass, but maybe there's more optimization to be had?

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.stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions