Big front-end learning---Node.js

What is Node.js?

Node.js is actually similar to the jdk that the java program depends on. The helper program runs on the server side, and Node.js allows our JavaScript program to run on the server side, including vue is also dependent on node.js.

One, install Node.js

Click the link: to download directly, open cmd after installation, enter node -v, and the pop-up version number means the installation is successful!

Insert picture description here

It should be noted that after we installed node, npm is also installed by default. npm is a dependency management tool, similar to Maven.

Enter npm -v and the corresponding version number will appear.

Insert picture description here

Two, use Node to run js

const http=require('http');
    //告诉浏览器怎么 解析

    response.end("hello node server!!!")
console.log("node server服务已经启动!!");
Insert picture description here

Three, use node.js to connect to MySQL

var mysql=require ("mysql")  //1.导入依赖
const { rootCertificates } = require("tls")

var connection=mysql.createConnection({
    port: 3306,
    user: "root",

connection.query("select * from stud",function(error,results,fields){
    if(error) throw error;
Insert picture description here