node package manage
NodeJs 中包管理及分发工具。
NPM - Node Package Manager
node 包管理工具,是全球最大的开源库生态系统。
网络环境,node 包安装或下载速度慢时,可使用淘宝 npm 镜像 cnpm
1 | # npm install -g cnpm --registry=https://registry.npm.taobao.org |
1 | Usage: npm <command> |
退出 node 环境
- 两次ctrl+C
- 一次ctrl+D
process.exit()
- .exit
npm 库
命令行界面解决方式
The complete solution for node.js command-line interfaces
postcss-pxtorem
react-app-polyfill
babel-polyfill 重写,适用于 react 框架,用于ES6 内置 API 兼容处理,使用方法
- 安装
npm i react-app-polyfill
- 入口引用,具体如下:
1
2
3// main.js
import "react-app-polyfill/IE11"
...
dotenv
NodeJs 运行时加载不同的配置,process.env.DB_HOST
获取环境变量,程序启动时,从文件加载环境变量时就需要用到 dotenv 库。
用法 创建 .env
1 | .env |
NODE 中运行
1 | const dotenv = require('dotenv') |
debug 专门控制日志输出的库
判断 DEBUG 环境变量,调整运行环境控制日志是否输出。DEBUG 对环境变量进行解析,允许我们选择性的控制输出哪些日志模块,解决控制台日志堆积的问题。