当前位置:网站首页>Nodejs初体验
Nodejs初体验
2022-07-25 09:25:00 【Zero摄氏度】
Nodejs详解
一、前端工具VsCode安装
- 官网下载:https://code.visualstudio.com/
- 安装即可
- 搜索插件:Chinese 汉化
- 本地创建文件夹—>然后在vscode中打开文件夹
- 修改字体大小等设置
二、Nodejs的安装
- 官网下载:http://nodejs.cn/
- 傻瓜式安装,一直next就好了
- 检验已经安装成功:
- cmd
- node -v
- 出现版本号:v18.4.0 则安装成功
三、Nodejs详解
1、nodejs概述
- Nodejs相当于java编程时安装的jdk;
- Chrom V8引擎:当安装好nodejs后,自动安装在系统中,把js文件解释给操作系统。相当于jvm:把class字节码文件解释给操作系统。
- Node是一个让JavaScript运行在服务端的开发平台,它让JavaScript成为与PHP等的脚本语言。
- 简单的来说,**Node.js就是运行在服务端的JavaScript ** 。底层结构是:javascript,文件后缀:js
- Node.js是一个事件驱动I/O服务端JavaScript环境。
2、nodejs入门
- 创建文件夹
- vscode中打开文件夹
- 新建一个js文件
console.log("hello xqh");
直接在终端打印
:node hello.js
ps:如果出现说“node识别不出,不是内部指令之类的”问题,可以试着关闭vscode,然后在vscode属性中,勾选以管理员身份打开,即可解决。
3、node实现请求响应
//导入模块是 require
const http = require('http');
//1:创建一个httpserver服务
http.createServer(function(request,response){
//浏览器怎么认识hello server
response.writeHead(200,{
'Content-type':'text/plain'});//告诉浏览器以什么方式来解析这段内容
//给浏览器输出内容
response.end("hello server!");
}).listen(8888);
console.log("你启动的服务是:http://localhost:8888 已启动成功!");
//2:监听一端口8888
//3:启动运行服务 node httpserver.js
//4:在浏览器访问http://localhost:8888
4、node 操作Mysql数据库
- cmd中命令:npm install mysql
- 下载mysql相关依赖,会在文件夹中出现相应的包
//导入mysql依赖包,mysql属于第三方的模块 var mysql = require("mysql"); //1:创建一个mysql的Connection对象 //2:配置数据连接的信息 var connection = mysql.createConnection({ host:"127.0.0.1", port:3306, user:"root", password:"123456", database:"testdb" }); //3:开辟连接 connection.connect(); //4:执行curd connection.query("select * from kss_user",function(error,results,fields){ if(error)throw error; console.log("results=",results); }); //5:关闭连接 connection.end(); //6:运行node db.js 查看效果
边栏推荐
- TensorFlow raw_rnn - 实现seq2seq模式中将上一时刻的输出作为下一时刻的输入
- Yolov5 realizes target detection of small data sets -- kolektor defect data set
- ARM GIC简介
- Arm preliminaries
- Gartner 2022年顶尖科技趋势之超级自动化
- Introduction to testbench
- Qt 6.2的下载和安装
- Mlx90640 infrared thermal imager temperature measurement module development notes (4)
- MLX90640 红外热成像仪测温模块开发笔记(一)
- OC -- Inheritance and polymorphic and pointer
猜你喜欢

【深度学习模型部署】使用TensorFlow Serving + Tornado部署深度学习模型

概率论与数理统计 4 Continuous Random Variables and Probability Distributions(连续随机变量与概率分布)(上篇)

~3 CCF 2022-03-2 travel plan
![[deployment of deep learning model] deploy the deep learning model using tensorflow serving + tornado](/img/62/78abf16bb6c66726c6e394c9fb4f81.png)
[deployment of deep learning model] deploy the deep learning model using tensorflow serving + tornado

工程监测无线中继采集仪和无线网络的优势

File -- first acquaintance

Yolov5 realizes target detection of small data sets -- kolektor defect data set

@5-1 CCF 2019-12-1 reporting

SystemVerilog syntax

ADC简介
随机推荐
I2C也可总线取电!
Development history of convolutional neural network (part)
GCD详解
T5论文总结
SOC芯片内部结构
Connection and data reading of hand-held vibrating wire vh501tc collector sensor
VScode配置ROS开发环境:修改代码不生效问题原因及解决方法
C语言基础
安装 oh my zsh
无线振弦采集仪的使用常见问题
小程序企业发放红包功能
MLX90640 红外热成像传感器测温模块开发笔记(二)
CCF 201512-4 送货
~2 CCF 2022-03-1 uninitialized warning
rospy Odometry天坑小计
数字IC设计SOC入门进阶
TensorFlow raw_ RNN - implement the seq2seq mode to take the output of the previous time as the input of the next time
TM1637带秒点四位LED显示器模块ARDUINO驱动程序
Mlx90640 infrared thermal imaging sensor temperature measurement module development notes (II)
从Anaconda到TensorFlow到Jupyter一路踩坑一路填平