Version
27.2.4
Steps to reproduce
See repo README at https://github.com/ekelen/jest-require-resolve-empty-paths-array
OR:
- Clone reproduction repo linked above and change current directory to repo root.
- Run
cp test.js /tmp && node -p "require.resolve('/tmp/test', { paths: [] } )" (returns path of tmp/test.js at filesystem root).
- Run
yarn install.
- Run
yarn test.
Expected behavior
No error should be thrown when require.resolve is called with a valid module at user's filesystem root and an empty paths array option.
The output of require.resolve("/tmp/test", { paths: ["/"] }) should match the output of require.resolve("/tmp/test", { paths: [] }).
Actual behavior
If provided an empty paths array, ModuleNotFoundError is thrown: Cannot resolve module '/tmp/test' from paths [''] from <repo_root>/test.js.
Additional context
Appears to be a parallel issue to #9502.
Environment
System:
OS: macOS 11.5.2
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 16.8.0 - ~/.volta/tools/image/node/16.8.0/bin/node
Yarn: 1.22.15 - ~/.volta/tools/image/yarn/1.22.15/bin/yarn
npm: 7.21.0 - ~/.volta/tools/image/node/16.8.0/bin/npm
npmPackages:
jest: 27.2.4 => 27.2.4
Version
27.2.4
Steps to reproduce
See repo README at https://github.com/ekelen/jest-require-resolve-empty-paths-array
OR:
cp test.js /tmp && node -p "require.resolve('/tmp/test', { paths: [] } )"(returns path oftmp/test.jsat filesystem root).yarn install.yarn test.Expected behavior
No error should be thrown when
require.resolveis called with a valid module at user's filesystem root and an emptypathsarray option.The output of
require.resolve("/tmp/test", { paths: ["/"] })should match the output ofrequire.resolve("/tmp/test", { paths: [] }).Actual behavior
If provided an empty paths array,
ModuleNotFoundErroris thrown:Cannot resolve module '/tmp/test' from paths [''] from <repo_root>/test.js.Additional context
Appears to be a parallel issue to #9502.
Environment
System: OS: macOS 11.5.2 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Binaries: Node: 16.8.0 - ~/.volta/tools/image/node/16.8.0/bin/node Yarn: 1.22.15 - ~/.volta/tools/image/yarn/1.22.15/bin/yarn npm: 7.21.0 - ~/.volta/tools/image/node/16.8.0/bin/npm npmPackages: jest: 27.2.4 => 27.2.4