smuggledPancakes
smuggledPancakes

Reputation: 10333

How to stop Yarn Package Manager script from CLI

https://yarnpkg.com/en/docs/cli/

Is there a way to stop what is started from the command yarn run? Is my only option to lookup the process number and call kill on it?

Upvotes: 15

Views: 72604

Answers (3)

Dilip Muthukurussimana
Dilip Muthukurussimana

Reputation: 709

I know this is a well-answered question. However, it behaved once very strange when I was running a sample React code which was auto-created by the create-react-app CLI, on my Windows 10.

After hitting Ctrl+C, which is the most suggested standard way to stop the yarn run, though I got back the command prompt, there was a ghost process lingering around there, which was still actively listening to 3000(default) port, and localhost:3000 was working as normal.

So finally this is how I fixed it:

  • netstat -ano | grep ":3000" (yeah, I ran this from my git-bash instead of command prompt!)
  • Noted down the PID of the line where it says LISTENING on 3000
  • Pressed Ctrl+Shift+Esc to open the Task Manager
  • Went to the Process tab
  • Right clicked on one of the headings, say Name
  • Selected PID --> This added the PID column to the display
  • Located the PID in question
  • Right clicked on it and clicked "End task"

Luckily Windows knew how to kill that misbehaving, ghost process and the port became free for me.

NOTE: Prior to the above-mentioned steps, I tried to kill that PID from git-bash using the famous (or notorious as per its meaning?? >8)) kill -9 command. It was responding back with no such PID msg, however netstat -ano was clearly displaying the PID and browser was proving that the ghost process is up and alive!!

Upvotes: 4

Mr-Programs
Mr-Programs

Reputation: 827

I had a similar issue having it running after ctl+c and then I thought, maybe it is just running on the cache

so went to http://localhost:3000/

ctrl+F5

which forces refresh without cache showed me that the actual project wasn't really running anymore!

;)

*hadn't it worked I would have had to sudo kill the 3000 port

Upvotes: 3

galkin
galkin

Reputation: 5519

The usual way ctrl-c should work. If it doesn't work, than you have bug in the script. The script's author missed handler for shutdown (SIGINT/SIGTERM/etc).

Upvotes: 34

Related Questions