Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run package json script #462

Open
mxxnseat opened this issue Dec 15, 2023 · 4 comments
Open

Can't run package json script #462

mxxnseat opened this issue Dec 15, 2023 · 4 comments

Comments

@mxxnseat
Copy link

mxxnseat commented Dec 15, 2023

Expected Behavior

I can run package.json script from command line with clinic heapprofiler
clinic heapprofiler -- yarn test

Current Behavior

I can't run(or profile is empty) package.json script from command line with clinic heapprofiler clinic heapprofiler -- yarn test
I get error - Clinic.js must be called with a node command line: clinic heap-profiler -- node script.js

I also tried to do next but profile is empty
clinic heapprofiler -- node /home/mxxnseat/.nvm/versions/node/v18.16.1/bin/yarn test
image

My package.json test script - yarn clean && TS_NODE_PROJECT=tsconfig.spec.json nyc -t .nyc_output_integration mocha --config test/integration/.mocharc.yaml

Also I can't use node /node_modules/[module].js as I use pnp node_linker in yarn config and I have zipped modules

Steps to Reproduce (for bugs)

Sample upload

Environment

  • Clinic.js version: 13.0.0
  • heapprofile: 5.0.0
  • Node.js version: v18.16.1
  • Npm version: 9.5.1
  • yarn version: 3.6.0
  • typescript version: 4.6.4
  • Mocha version: 10.2.0
  • Operating system and version: Ubuntu 22.04
@alfonsograziano
Copy link

Hey! This sounds like a really specific use-case. Can you please provide a minimal repository to reproduce your issue?

In every case, Clinic.js relies heavily on Node.js core instrumentation. That's why you need to run it with a node command.
If you run any other command, Clinic will not be able to read the data coming from the Node process

@tushar32
Copy link

tushar32 commented Jan 8, 2024

I also have the same issue.

My application is running with below command
ts-node -r tsconfig-paths/register src/index.ts

But clinic js enforces to use -- node so I dont think that it supports ts-node..

@alfonsograziano is it true?

@alfonsograziano
Copy link

alfonsograziano commented Jan 8, 2024

Yes correct. What you can do is to compile your Typescript in a dist folder, and then run node dist/index.js with clinic.
You just need to perform two steps instead of one :)

@RafaelGSS
Copy link
Contributor

@tushar32 you can run it by:

$ node ./node_modules/.bin/ts-node -r tsconfig-paths/register src/index.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants