node中npm的常用命令
关于版本
node -v
npm -v
或
npm -version
npm -versions
{
npm: '6.14.17',
ares: '1.18.1',
brotli: '1.0.9',
cldr: '40.0',
icu: '70.1',
llhttp: '2.1.6',
modules: '83',
napi: '8',
nghttp2: '1.42.0',
node: '14.21.1',
openssl: '1.1.1q',
tz: '2022e',
unicode: '14.0',
uv: '1.42.0',
v8: '8.4.371.23-node.87',
zlib: '1.2.11'
}
npm config ls -l
npm list
npm list -g
npm view vue
npm view vue version
npm view vue versions
npm install xxx
npm install -g xxx
npm install xxx --save
npm install xxx@3.0.0
~会匹配最近的小版本依赖包,比如~1.2.3会匹配所有1.2.x版本,但是不包括1.3.0
^会匹配最新的大版本依赖包,比如^1.2.3会匹配所有1.x.x的包,包括1.3.0,但是不包括2.0.0
*会安装最新版本的依赖包
npm update xxx
npm update xxx@1.0.0
npm update -g xxx
npm update -g xxx@1.0.0
npm unistall xxx
npm uninstall --save xxx
npm uninstall -g xxx
npm run dev
npm run build
npm cache clean --force
npm install -g rimraf
rimraf node_modules
npm -h
Usage: npm <command>
where <command> is one of:
access, adduser, audit, bin, bugs, c, cache, ci, cit,
clean-install, clean-install-test, completion, config,
create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
edit, explore, fund, get, help, help-search, hook, i, init,
install, install-ci-test, install-test, it, link, list, ln,
login, logout, ls, org, outdated, owner, pack, ping, prefix,
profile, prune, publish, rb, rebuild, repo, restart, root,
run, run-script, s, se, search, set, shrinkwrap, star,
stars, start, stop, t, team, test, token, tst, un,
uninstall, unpublish, unstar, up, update, v, version, view,
whoami
npm <command> -h quick help on <command>
npm -l display full usage info
npm help <term> search for help on <term>
npm help npm involved overview