Open valeneiko opened 1 year ago
What's the content of index.js
?
Dosn't really matter. Just a simple hello world reproduces the issue.
"use strict";
function main() {
console.log('Hello, World!');
}
void main();
I couldn't reproduce it locally. You are gettingundefined
because you have a typo and index/js
doesn't exist.
- Run clinic flame: pnpm exec clinic flame -- node ./src/index/js
+ Run clinic flame: pnpm exec clinic flame -- node ./src/index.js
The typo was only in the GitHub issue, not the command I was running. Sorry about that. I will create a repo to reproduce it later today.
Here is the repo that reproduces the issue: https://github.com/valeneiko/clinic-bug
I couldn't reproduce the issue initially either, but pnpm audit --fix
, made it fail like described. I think it's the fact that d3-color
gets updated to a more recent version.
I'm not a pnpm
user so I don't know exactly what's going on. However, I couldn't reproduce it with npm
, I assume pnpm
is loading the clinic
outside of node_modules/.bin/clinic
.
I added equivalent npm
lockfile, it is now reproducible with npm
too: https://github.com/valeneiko/clinic-bug
So I ran into this same issue. It's worth mentioning that using pnpm / pnpx for everything is necessary in a pnpm project. My guess is that clinic is having issues resolving pnpm node_modules structure (symlinks) when npm / npx is used. Running it raw without pnpx also fails FYI.
Does not work:
pnpm run build && npx clinic flame -- node dist/test.js
Does work:
pnpm run build && pnpx clinic flame -- node dist/test.js
I would recommend detected a pnpm project and print a warning under these conditions.
Summary
If I install clinic as a project dependency for a CJS project, or use
pnpm exec
from inside a CJS project to run it, clinic fails to generate report with no obvious error. It fails to build CSS styles, because it tries to load ESM version ofd3-color
(from theirsrc
folder instead ofdist
), which results in an invalid syntax error that is never surfaced. Instead clinic just exits with an incomplete report andundefined
log in the console.Expected Behavior
Clinic correctly generates report (by loading appropriate version of the library depending of the environment), or prints an error explaining how to fix it: installing clinic globally and invoking it directly.
Current Behavior
Process encounters an error, prints
undefined
to console and exits. The generated HTML report is cut at the opening<style>
tag, like shown below (this is the entire contents of the file):Steps to Reproduce (for bugs)
pnpm i -D clinic
pnpm exec clinic flame -- node ./src/index.js
undefined
log in console and an incomplete HTML reportEnvironment