nyc@15 crashes when spawning a different Node.js version
See original GitHub issueLink to bug demonstration repository
https://github.com/ehmicky/nyc-bug-repro
Expected Behavior
nyc
should not crash when spawning a different Node.js version than the current one.
This happens for example when using nvm or similar tools.
Observed Behavior
nyc
crashes.
Troubleshooting steps
index.js
:
const { spawn } = require("child_process");
const { homedir } = require("os");
const nodePath = `${homedir()}/.nvm/versions/node/v11.15.0/bin/node`;
spawn(nodePath, ["--help"], { stdio: "inherit" });
$ nvm install 11.15.0
$ nvm install 12.0.0
$ nvm use 12.0.0
$ npm install
$ nyc node index.js
internal/modules/cjs/loader.js:670
throw err;
^
Error: Cannot find module '"/home/user/nyc-bug-repro/node_modules/node-preload/preload-path/node-preload.js"'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:668:15)
at Function.Module._load (internal/modules/cjs/loader.js:591:27)
at Module.require (internal/modules/cjs/loader.js:723:19)
at Module._preloadModules (internal/modules/cjs/loader.js:945:12)
at loadPreloadModules (internal/bootstrap/pre_execution.js:363:5)
at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:61:3)
at internal/main/print_help.js:180:1
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
index.js | 100 | 100 | 100 | 100 |
----------|---------|----------|---------|---------|-------------------
Notes
Please note the following bug only happens when:
- the current Node.js version is
>= 12
- the spawned Node.js version is
< 12
Also this only happens with nyc@15
. I cannot use --use-spawn-wrap=true
because spawn-wrap
has its own sets of bugs that node-preload
fixes.
The index.js
file is spawning a node binary directly via its absolute path. This is only to make it easy to reproduce. In real life, this would be done when the PATH
environment variable points to a different Node.js version, which happens when using nvm run
and other tools.
Environment Information
System:
OS: Linux 5.3 Ubuntu 19.10 (Eoan Ermine)
CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
Memory: 51.92 GB / 62.76 GB
Binaries:
Node: 12.0.0 - ~/.nvm/versions/node/v12.0.0/bin/node
npm: 6.9.0 - ~/.nvm/versions/node/v12.0.0/bin/npm
npmPackages:
nyc: ^15.0.0 => 15.0.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Reattaching to spawned process via nodejs - Stack Overflow
I am creating a small proprietary game server manager in Node.js; currently it runs the game by spawning via child_process : var server...
Read more >6 reasons your Node.js apps are failing - IBM Developer
Unresponsive application, possibly looping or hanging; Poor performance; Crash or abort in native code; Unexpected application behavior or functional issue. The ...
Read more >Child process | Node.js v19.3.0 Documentation
fork() : spawns a new Node.js process and invokes a specified module with an IPC communication channel established that allows sending messages between...
Read more >[MC-250349] Server crashes when spawning wither - Jira
The server crashes when we spawn in a wither on version 22w16b. Crash logs and a part of the console log are attached...
Read more >Troubleshooting - Puppeteer
For the former, we do not support deprecated versions of Node.js. ... If there's no good sandbox for Chrome to use, it will...
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
@XhmikosR would you mind opening a new issue including a link to a repo and any special instructions for how to reproduce the issue?
Thanks a lot Corey! Thanks also for the v15 update, dropping
spawn-wrap
fixed many problems for me.