JMS786
JMS786

Reputation: 1109

How to stop npm serve

I've build React Apps:

npm run build

and installed globally serve package:

npm install -g serve

and run it:

serve -s build

How do I stop it?

I've tried serve help but it doesn't show any stop option

Options:

-a, --auth      Serve behind basic auth
-c, --cache     Time in milliseconds for caching files in the browser
-n, --clipless  Don't copy address to clipboard (disabled by default)
-C, --cors      Setup * CORS headers to allow requests from any origin (disabled by default)
-h, --help      Output usage information
-i, --ignore    Files and directories to ignore
-o, --open      Open local address in browser (disabled by default)
-p, --port <n>  Port to listen on (defaults to 5000)
-S, --silent    Don't log anything to the console
-s, --single    Serve single page applications (sets `-c` to 1 day)
-u, --unzipped  Disable GZIP compression
-v, --version   Output the version number

Upvotes: 36

Views: 120721

Answers (5)

brugobi
brugobi

Reputation: 257

You can use the command below:

$ killall -9 node

Upvotes: 12

David Melkumyan
David Melkumyan

Reputation: 427

Just close "local console" on which you were ran your npm

Upvotes: 1

Choxmi
Choxmi

Reputation: 1664

I had the same problem when using serve for production build. I terminated the port instead of stopping Serve.

sudo fuser -k <portno>/tcp

Upvotes: 6

Alonso Robles
Alonso Robles

Reputation: 401

I had the same problem using serve to serve the production build of my react app (built from create-react-app).

I was able to finally kill it by using serve again somewhere else on my filesystem (like my home directory and then killing it with: Ctrl + c.

You can do something like this to kill your react app being served by serve:

> cd ~
> serve

And then use Ctrl + c

Then go to http://localhost:5000 to confirm nothing is being served.

Upvotes: 12

Marc Scheib
Marc Scheib

Reputation: 2009

You can stop the process on the console like any other process: Ctrl + c.

See https://superuser.com/questions/103909/how-to-stop-a-process-in-terminal

Upvotes: 45

Related Questions