[Bug]: require.resolve.paths cannot reach global path in the scope of jest
See original GitHub issueVersion
v29.1.2, the newest
Steps to reproduce
Minimal reproduction: https://github.com/lvqq/jest-require-resolve-paths
Steps:
npm install
npm test
Expected behavior
require.resolve.paths
is consistent in jest and in node
Actual behavior
In node, require.resolve.paths(‘npm’) returns:
[
'D:\\RD\\project\\jest-require-resolve-paths\\node_modules',
'D:\\RD\\project\\node_modules',
'D:\\RD\\node_modules',
'D:\\node_modules',
'C:\\Users\\chlorine\\.node_modules',
'C:\\Users\\chlorine\\.node_libraries',
'D:\\RD\\nodejs\\lib\\node'
]
In the scope of jest, require.resolve.paths(‘npm’) returns:
[
'D:\\RD\\project\\jest-require-resolve-paths\\node_modules',
'D:\\RD\\project\\node_modules',
'D:\\RD\\node_modules',
'D:\\node_modules'
]
The global paths are missing.
Additional context
No response
Environment
System:
OS: Windows 10 10.0.19044
CPU: (16) x64 Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz
Binaries:
Node: 16.17.0 - D:\RD\nodejs\node.EXE
Yarn: 1.22.10 - D:\RD\nodejs\node_global\node_modules\yarn\bin\yarn.CMD npm: 8.15.0 - D:\RD\nodejs\npm.CMD
npmPackages:
jest: ^29.1.2 => 29.1.2
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Using eslint with typescript - Unable to resolve path to module
As soon as I compile the .ts file to a .js, the error goes away. However, since eslint is supposed to work with...
Read more >Configuring Jest
To read TypeScript configuration files Jest requires ts-node . ... Thresholds can be specified as global , as a glob, and as a...
Read more >Configuring code coverage in Jest, the right way
Code coverage makes possible to spot untested paths in our code. It is an important metric for determining the health of a project....
Read more >CommonJS modules | Node.js v19.3.0 Documentation
If the module can not be found, a MODULE_NOT_FOUND error is thrown. require.resolve.paths(request) #. Added in: v8.9.0. request ...
Read more >Requiring modules in Node.js: Everything you need to know
The require module, which appears to be available on the global scope — no need to ... If Node can't find find-me.js in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Cool! In case this helps your get started:
require
andrequire.resolve
andrequire.resolve.paths
are implemented byjest-runtime
, which then does some calls tojest-resolve
which knows things like how to look up in the directory tree to look fornode_modules
etc.Thanks! I’d like to work on implementing it