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

  这样设置以后就可以使用 cnpm 命令来安装模块了:

cnpm install express

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM