question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nyc 15 gives no coverage without the useSpawnWrap option when using pnpm

See original GitHub issue

Since this issue https://github.com/istanbuljs/nyc/issues/1303#issue-598938132 has been closed, so I think it is better to up a new one.

@coreyfarrell I can reproduce this issue by using the @adjerbetian’s git repo: https://github.com/adjerbetian/nyc-bug-demo-use-spawn

My desktop is Windows 10 10.0.19041.208, and the node.js environment is:

  • node.js: 12.16.2, installed by nvs
  • npm: 6.14.4

The reproduce steps:

internal/modules/cjs/loader.js:983
  throw err;
  ^

Error: Cannot find module 'node-preload.js'
Require stack:
- internal/preload
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
    at Function.Module._load (internal/modules/cjs/loader.js:862:27)
    at Module.require (internal/modules/cjs/loader.js:1042:19)
    at Module._preloadModules (internal/modules/cjs/loader.js:1296:12)
    at loadPreloadModules (internal/bootstrap/pre_execution.js:444:5)
    at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:68:3)
    at internal/main/run_main_module.js:7:1 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'internal/preload' ]
}
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |
----------|---------|----------|---------|---------|-------------------
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-ts@1.0.0 nyc:wrong: `nyc mocha`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test-ts@1.0.0 nyc:wrong script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  • run npm run nyc:correct will ok to get good result:
> nyc --use-spawn-wrap mocha



  plus
    √ should add 2 numbers


  1 passing (11ms)

--------------|---------|----------|---------|---------|-------------------
File          | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------|---------|----------|---------|---------|-------------------
All files     |     100 |      100 |     100 |     100 |
 plus.js      |     100 |      100 |     100 |     100 |
 plus.spec.js |     100 |      100 |     100 |     100 |
--------------|---------|----------|---------|---------|-------------------

If I repeat above steps in the WSL2, they are all ok except not so good performance.

But, If i use npm install in both of Windows and WSL2, they are all good.

Then, I guess the package node-preload cannot handle links from pnpm installation on Windows.

Expected Behaviour:

  • Support pnpm install on Windows

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
coreyfarrellcommented, May 3, 2020

I would advise against downgrading to nyc 14. For what it’s worth nyc 14 always uses spawn-wrap. NYC 15 has other big fixes so even with--use-spawn-wrap it is better than 14. I’ve seen situations where spawn-wrap simply doesn’t work in Windows but usually it either always or never works for a given project.

Switching away from pnpm is an option though I don’t want to throw shade at pnpm. If you have the ability to help them with a patch that would be great to see pnpm compatible with programs that need to append NODE_PATH.

0reactions
stale[bot]commented, Jun 18, 2021

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - No coverage nyc mocha - Stack Overflow
The recommended solution is to abandon nyc and use the native coverage now built into ... TL;DR: Try useSpawnWrap: true in your nyc...
Read more >
nyc - npm
Source maps are used to map coverage information back to the appropriate lines of the pre-transpiled code. You'll have to configure your custom ......
Read more >
.npmrc | pnpm
By default, pnpm creates a semistrict node_modules , meaning dependencies have access to undeclared dependencies but modules outside of node_modules do not.
Read more >
Installation | pnpm
Using Scoop​. If you have Scoop installed, you can install pnpm using the following command: scoop install nodejs-lts pnpm.
Read more >
Installation | pnpm
js is not preinstalled​. On POSIX systems, you may install pnpm even if you don't have Node.js installed, using the following script:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found