简单来讲,node.js 是一个让 JavaScript 运行在服务端的开发平台,让开发者经过JS编写服务端程序。html
从nodeJS官网下载对应平台的安装程序,安装完成后,打开命令行工具,而后输入node -v,若是安装正常,会显示对应的版本号。node
node.js 内置了一些基本模块算法
fs
模块就是文件系统模块,负责读写文件http
模块用来接收网络请求和处理网络请求crypto
模块的目的是为了提供通用的加密和哈希算法学习node,npm是必知的,npm 是node的包管理工具,经过npm使用第三方提供的模块,能够让咱们快速实现本身想要开发的功能,提升效率。咱们能够在终端中使用npm的命令安装npm
npm install [-g] <name>
:使用-g指令能够把nodule下载安装的nodejs的全局的path处,不加的话会安装到当前路径npm remove <name>
:移除 modulenpm update <name>
:更新 module用node实现一个服务器很是简单,只需几行代码便可服务器
const http = require('http') const app = http.createServer(); app.on('request', function (request, response) { response.write(`hello nodejs`) response.end() }) app.listen('3000', function () { console.log('this sevrver is running at http://127.0.0.1:3000/') })