Skip to content

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

Closed
@vsemozhetbyt

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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