Skip to content

require.resolve with options seems have different result in some case #9502

@fisker

Description

@fisker

🐛 Bug Report

require.resolve with options seems had different result in some case

require.resolve('foo/node_modules/bar', {paths: [process.cwd()]});

result differently with require.resolve from Node.js

To Reproduce

Steps to reproduce the behavior:

A reproduction repo https://github.com/fisker/jest-require-resolve-bug , see readme.md in that repo.

Expected behavior

Should try resolve foo package in node_modules, instead of returning foo/node_modules/bar/index.js file

Link to repl or repo (highly encouraged)

reproduction repo

https://github.com/fisker/jest-require-resolve-bug

issue found on this PR on prettier

prettier/prettier#7508

envinfo

  System:
    OS: Windows 10 10.0.18362
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  Binaries:
    Node: 13.5.0
    Yarn: 1.21.1
    npm: 6.13.4
  npmPackages:
    jest: 25.1.0 => 25.1.0

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