Skip to content

Requiring a dynamically added dependency fails when the package has no index.js file #44663

@zkochan

Description

@zkochan

Version

v7.1.0 and newer (last working version was v6.17.1)

Platform

Linux

Subsystem

No response

What steps will reproduce the bug?

Require a dependency that doesn't exist. Catch the error. Dynamically add the missing package to the node_modules. It should not contain an index.js file but should use a custom entry point instead. Require the now not missing package again.

Expected result: the modules is loaded.
Actual result: module not found error is thrown.

I have create a repro repo: https://github.com/zkochan/require-issue

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior?

No response

What do you see instead?

On the second require the module is loaded

Additional information

cc @GiladShoham @davidfirst

Metadata

Metadata

Assignees

No one assigned

    Labels

    esmIssues and PRs related to the ECMAScript Modules implementation.moduleIssues and PRs related to the module subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions