//导入模块是require 类似于import java.io
const http = require('http')
//创建httpserver服务
http
.createServer(function (request, response) {
//告诉浏览器将以text-plain去解析hello server
response.writeHead(200, { 'Content-type': 'text/plain' })
//输出内容给浏览器
response.end('hello server!!!')
})
.listen(8888)
console.log('你启动的服务是:http://localhost:8888')
//监听端口8888
//启动运行服务器node httpserver.js
//浏览器访问http://localhost:8888
npm | yarn | 注释 |
---|---|---|
npm init | yarn init | 初始化项目 |
npm install | yarn | 安装全部依赖 |
npm install react –save | yarn add react | 安装某个依赖,保存到 dependencies |
npm uninstall react –save | yarn remove react | 移除某个依赖 |
npm install react –save-dev | yarn add react –dev | 安装某依赖,保存到 devDependencies |
npm update [package] –save | yarn upgrade [package] | 更新生产环境某个依赖包 |
npm install axios –global | yarn global add axios | 全局安装某个依赖 |
npm install –save axios vue-axios | yarn add axios vue-axios | 同时下载多个依赖包 |
npm install [package]@[version] | yarn add [package]@[version] | 安装指定版本的包 |
npm rebuild | yarn install –force | 重新下载所有包 |