NPM常用命令install 淘宝镜像 update等
NPM是随同NodeJS一起安装的包管理工具,允许用户从NPM服务器上传下载安装第三方包或命令行程序,能解决NodeJS代码部署上的很多问题,非常方便。下面我们一起来看看常用的npm命令有哪些
使用方法:npm <command命令>,比如 npm -v表示查看版本号,以下是常用的命令
access, adduser, bin, bugs, c, cache, completion, config,
ddp, dedupe, deprecate, dist-tag, docs, doctor, edit,
explore, get, help, help-search, i, init, install,
install-test, it, link, list, ln, login, logout, ls,
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 install :表示用npm 安装 Node.js 模块,比如用 npm 命令安装常用的 Node.js web框架模块 express:
npm install express
npm update:升级更新模块
npm update express
npm uninstall:卸载模块
npm uninstall express
npm search:搜索模块
npm search express
npm 淘宝镜像:大家都知道国内直接使用 npm 的官方镜像是非常慢的,这里推荐使用淘宝 NPM 镜像。淘宝 NPM 镜像是一个完整 npmjs.org 镜像,你可以用此代替官方版本(只读),同步频率目前为 10分钟 一次以保证尽量与官方服务同步。你可以使用淘宝定制的 cnpm (gzip 压缩支持) 命令行工具代替默认的 npm:
npm install -g cnpm --registry=https://registry.npm.taobao.org
更新:原来的 registry.npm.taobao.org 已替换为 registry.npmmirror.com ,当点击 registry.npm.taobao.org 会默认跳转到 registry.npmmirror.com
npm config set registry https://registry.npmmirror.com
这样设置以后就可以使用 cnpm 命令来安装模块了:
cnpm install express
如果你想将npm的下载源恢复为默认的官方源,可以使用以下命令:
npm config set registry https://registry.npmjs.org
你可以使用以下命令来查看当前npm的下载源设置:
npm config get registry
加微信交流
浙公网安备 33010602011771号