Description
- I'd be willing to implement a fix
Describe the bug
When using PnP on Windows, running nyc
fails with the following error:
C:\path\to\project\.pnp.js:6338
throw firstError;
^
Error: Your application tried to access node-preload.js, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.
Required package: node-preload.js (via "node-preload.js")
Required by: C:\path\to\project\
Require stack:
- internal/preload
at internalTools_makeError (C:\path\to\project\.pnp.js:6082:34)
at resolveToUnqualified (C:\path\to\project\.pnp.js:7034:23)
at resolveRequest (C:\path\to\project\.pnp.js:7132:29)
at Object.resolveRequest (C:\path\to\project\.pnp.js:7198:26)
at Function.external_module_.Module._resolveFilename (C:\path\to\project\.pnp.js:6315:34)
at Function.external_module_.Module._load (C:\path\to\project\.pnp.js:6180:48)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at Module._preloadModules (internal/modules/cjs/loader.js:1345:12)
at loadPreloadModules (internal/bootstrap/pre_execution.js:439:5)
at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:71:3)
This does not happen and nyc
correctly collects coverage when:
- using the
node-modules
linker - running
nyc
inside a docker container using WSL2 backend - running
nyc
on a Linux (specifically CentOS 7) VM
To Reproduce
The minimal information needed to reproduce your issue (ideally a package.json with a single dep). Note that bugs without minimal reproductions might be closed.
IMPORTANT: We strongly prefer reproductions that use Sherlock. Please check our documentation for more information: https://yarnpkg.com/advanced/sherlock
Reproduction
const { promises: { writeFile } } = require('fs')
await packageJsonAndInstall({
devDependencies: {
nyc: '^15.1.0'
}
})
await writeFile('test.js', 'console.log("test")')
await expect(yarn('nyc', 'node', 'test.js')).resolves.toBeTruthy()
Environment if relevant (please complete the following information):
- OS: Windows 10 Home Build 19041.508
- Node version: 14.11.0, 12.18.4
- Yarn version: 2.2.2, 2.2.2-git.20200914.bc3c466e
Additional context
istanbuljs/nyc#1308 probably relevant? However, unlike pnpm
, running yarn nyc --use-spawn-wrap
(Windows, PnP) will cause nyc
to not run the given test command at all and collects no coverage.
Activity