1.开发环境的配置
1.node.js2.配置cnpmnpm install -g cnpm --registry=https://registry.npm.taobao.org#如果输出不是内部或者外部命令配置一下环境变量的path路径
2.配置
//卸载某个依赖cnpm uninstall xxx -S
cnpm i axios -S //安装了axios
//index.jsconst url = "xxx";/* 不写路径就会自动到node_modules这个包里面找 */const axios = require("axios");axios.get(url).then(res=>{ console.log(res.data)})
node index.js
3.启动服务
# 安装依赖cnpm i koa -S
/* 1.导入koa */const koa = require("koa");/* 2.新建一个应用 */const app = new koa();app.use(async ctx=>{ ctx.body = "hello world"})app.listen(8000)
node index.js //启动服务
4.安装nodemon
cnpm i nodemon -g //实时监听
5修改package.json文件启动服务
{ "scripts":{ "start" : "nodemon index.js" }}