Skip to content

Module.createRequireFromPath() is deprecated. #746

Description

@sraka1

Environment

Node v13.8.0

Description

Module.createRequireFromPath() is deprecated since Node v12.2.0. An error is thrown when it is used on v13.

Reproducible Demo

Use haul in a project with Node version > 13.

Proposed fix

In

// Create resolver for this module.
something like the following could be implemented (to main compatibility with Node 10-12)

  const createRequireWrapper = Module.createRequire || Module.createRequireFromPath
  // Create resolver for this module.
  const currentResolve = ((createRequireWrapper(
    module.filename
  ) as unknown) as {
    resolve: RequireResolve;
  }).resolve;

The method seems to be identical in function, only its naming has changed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions