Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I stop webpack dev server from windows console?

I run webpack-dev-server from windows console with the command:

webpack-dev-server --content-base ./build --inline --hot

after this I see message webpack: bundle is now VALID. and I can't type anything there. But if I change something in webpack.config.js I have to close console, open it again and start webpack-dev-server for apply my changes. How can I stop webpack dev server without close console?

like image 687
Rajab Shakirov Avatar asked Apr 28 '16 17:04

Rajab Shakirov


People also ask

How do I stop the dev server in react?

To stop this from running, in the command prompt, type CTRL-C. You will get the prompt to Terminate batch job: Type Y and the app will stop running: You can now run npm start again if you want to relaunch the app.

Is webpack-dev-server necessary?

And if I want to use react-hot-loader, is the webpack-dev-server necessary? Nope, it works on top of Webpack's hot module replacement interface. You can create your own 'hot server' if you want.

How do I find the webpack-dev-server file?

This means that if you're trying to figure out where your compiled files are going, you won't see them in a directory. To see where they're going, go to localhost:8080/webpack-dev-server.

What is the default port where webpack-dev-server will run?

The Result Either method will start a server instance and begin listening for connections from localhost on port 8080 . webpack-dev-server is configured by default to support live-reload of files as you edit your assets while the server is running. See the documentation for more use cases and options.


4 Answers

You only need to type Ctrl+C two times

like image 188
thitemple Avatar answered Oct 08 '22 16:10

thitemple


I run webpack devserver by issuing the "npm start" command. I've found that CTRL+C doesn't work for me and just creates an orphaned process. I'm able to kill the devserver by opening the task manager and killing any running node.exe processes.

Another way to do this from plain jane windows console is to find the node process Ids and kill them.

tasklist /FI "IMAGENAME eq node.exe"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
node.exe                      4620 Console                    2     44,568 K
node.exe                     12452 Console                    2    486,260 K

Then kill them with the following command.

taskkill /F /PID 4620 /PID 12452

An alternative more direct approach as pointed out by a comment.

taskkill /F /IM node.exe
like image 34
Jason Slobotski Avatar answered Oct 08 '22 17:10

Jason Slobotski


I have also been running into this hard-to-kill webpack-dev-server process on my Windows machine lately.

Ctrl+C/break and even closing were getting me nowhere and I quickly tired of manually tracking down the process and killing it.

This one-liner did the trick for me:

for /f "tokens=5" %a in ('netstat -aon ^| findstr 8080 ^| findstr LISTENING') do taskkill /pid %a /f

I went ahead and made a kill-server.bat file for it:

@echo off
for /f "tokens=5" %%a in ('netstat -aon ^| findstr %1 ^| findstr LISTENING') do taskkill /pid %%a /f && echo killed PID %%a

I put that on my PATH, so now to kill a server using a specific port I can just:

kill-server 8080

On a side note, this issue seems to happen for me only when I use console emulation tools, not when I am using the windows command prompt directly.

like image 5
Jordan Watkins Avatar answered Oct 08 '22 17:10

Jordan Watkins


On Windows this Powershell seems to kill it (and all Node processes!)

get-process node | Stop-Process
like image 2
Damien Sawyer Avatar answered Oct 08 '22 16:10

Damien Sawyer