Skip to content

module: require.resolve() / require.resolve.paths() to fail early? #18352

Description

@vsemozhetbyt
  • Version: 4 - 10
  • Platform: any?
  • Subsystem: module

Compare:

> module.require(1)
AssertionError: path must be a string // Node.js v4-v6
AssertionError [ERR_ASSERTION]: path must be a string // Node.js v8-v10

VS

> require.resolve(1)
TypeError: request.substring is not a function // Node.js v4
TypeError: request.charCodeAt is not a function // Node.js v6-v10
> require.resolve.paths(1)
TypeError: request.charCodeAt is not a function // Node.js v8-v10

It seems a bit confusing error message, so maybe we need to add a type check and throw early. On the other hand, I am not sure how thoroughly we check API arguments, so maybe it is OK as it is.

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

    Labels

    moduleIssues and PRs related to the module subsystem.questionIssues asking questions about Node.js.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions