Nodejs和NPM

235 阅读1分钟

nodejs安装

  • 下载:Node.js — Download Node.js®
  • 修改包的默认安装位置:
    • npm config set prefix "D:\nodejs\node_global"
    • npm config set cache "D:\nodejs\node_cache"
  • npm安装的包会存放在D:\nodejs\node_global目录下,将D:\nodejs\node_global添加到系统环境变量
  • 设置镜像源:npm config set registry https://registry.npmmirror.com(这是最新的淘宝镜像源)
  • 安装cnpm:npm install -g cnpm --registry=https://registry.npmmirror.com

npm命令

  • 全局安装:npm i 包名 -g
  • 项目安装:npm i 包名 -S
  • 查看安装的包:npm list -g
  • 卸载安装的包:npm uninstall -g 包名