Node về Nodejs

sudo apt-get install nodejs npm

Kiểm tra cài nodejs chưa

node -v

npm -v

Tuy nhiên lúc cài xong thì gặp vấn đề thế này

apt install nodejs-legacy

Sau khi cài lại thì đã ok

Cài đặt package Nodejs

npm install <package_name>

npm install express

npm install ejs

Tạo thư mục làm việc với nodejs

cd <thư_mục>

npm init

Khởi chạy nodejs

node <file_name>.js

Tìm hiểu Nodejs

Stop all instances of node.js server

Windows Machine:

Need to kill a Node.js server, and you don’t have any other Node processes running, you can tell your machine to kill all processes named node.exe. That would look like this:

And if the processes still persist, you can force the processes to terminate by adding the /f flag:

If you need more fine-grained control and need to only kill a server that is running on a specific port, you can use netstat to find the process ID, then send a kill signal to it. So in your case, where the port is 8080, you could run the following:

The fifth column of the output is the process ID:

You could then kill the process with taskkill /pid 14828. If the process refuses to exit, then just add the /f (force) parameter to the command.

Linux machine:

The process is almost identical. You could either kill all Node processes running on the machine (use -$SIGNAL if SIGKILL is insufficient):

Or also using netstat, you can find the PID of a process listening on a port:

The process ID in this case is the number before the process name in the sixth column, which you could then pass to the kill command:

If the process refuses to exit, then just use the -9 flag, which is a SIGTERM and cannot be ignored: