1、安装nodejs,直接在官网下载即可;
下载地址:http://cdn.npm.taobao.org/dist/node/v8.2.1/node-v8.2.1-x64.msi
2、查看npm配置:
C:\Users\10375>npm config list -l
; cli configs
long = true
user-agent = "npm/3.10.10 node/v6.10.3 win32 x64"
; builtin config undefined
prefix = "C:\\Users\\10375\\AppData\\Roaming\\npm"
; default values
access = null
also = null
always-auth = false
bin-links = true
browser = null
ca = null
cache = "C:\\Users\\10375\\AppData\\Roaming\\npm-cache"
cache-lock-retries = 10
cache-lock-stale = 60000
cache-lock-wait = 10000
cache-max = null
cache-min = 10
cafile = undefined
cert = null
color = true
depth = null
description = true
dev = false
dry-run = false
editor = "notepad.exe"
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
force = false
git = "git"
git-tag-version = true
global = false
global-style = false
globalconfig = "C:\\Users\\10375\\AppData\\Roaming\\npm\\etc\\npmrc"
globalignorefile = "C:\\Users\\10375\\AppData\\Roaming\\npm\\etc\\npmignore"
group = 0
heading = "npm"
https-proxy = null
if-present = false
ignore-scripts = false
init-author-email = ""
init-author-name = ""
init-author-url = ""
init-license = "ISC"
init-module = "C:\\Users\\10375\\.npm-init.js"
init-version = "1.0.0"
json = false
key = null
legacy-bundling = false
link = false
local-address = undefined
loglevel = "warn"
; long = false (overridden)
maxsockets = 50
message = "%s"
node-version = "6.10.3"
npat = false
onload-script = null
only = null
optional = true
parseable = false
; prefix = "C:\\Program Files\\nodejs" (overridden)
production = false
progress = true
proprietary-attribs = true
proxy = null
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
rollback = true
save = false
save-bundle = false
save-dev = false
save-exact = false
save-optional = false
save-prefix = "^"
scope = ""
searchexclude = null
searchopts = ""
searchsort = "name"
shell = "C:\\WINDOWS\\system32\\cmd.exe"
shrinkwrap = true
sign-git-tag = false
strict-ssl = true
tag = "latest"
tag-version-prefix = "v"
tmp = "C:\\Users\\10375\\AppData\\Local\\Temp"
umask = 0
unicode = false
unsafe-perm = true
usage = false
user = 0
; user-agent = "npm/{npm-version} node/{node-version} {platform} {arch}" (overridden)
userconfig = "C:\\Users\\10375\\.npmrc"
version = false
versions = false
viewer = "browser"
3、使用npm国内镜像
设置镜像为淘宝的镜像,速度很快!
npm config set registry https://registry.npm.taobao.org
4、单独更新npm
npm install npm@latest -g
5、安装包
npm install <package_name>
#写入package.json文件
npm install <package_name> --save
npm install <package_name> --save-dev
6、卸载包
npm uninstall --save <package_name>