使用npm更新已有模块

使用npm-check-updates模块升级插件

安装

npm install -g npm-check-updates

查看安装版本

ncu - v   # ncu是npm-check-updates的缩写命令

查看帮助

$ ncu --help
Usage: ncu [options] [filter]

[filter] is a list or regex of package names to check (all others will be ignored).

Options:

  -d, --dev                    check only devDependencies
  -e, --error-level <n>        set the error-level. 1: exits with error code 0 if no errors occur. 2: exits with error code 0 i
f no packages need updating (useful for continuous integration). Default is 1. (default: 1)
  -f, --filter <matches>       include only package names matching the given string, comma-delimited list, or regex
  -g, --global                 check global packages instead of in the current project
  -j, --jsonAll                output new package file instead of human-readable message
  --jsonUpgraded               output upgraded dependencies in json
  -l, --loglevel <n>           what level of logs to report: silent, error, minimal, warn, info, verbose, silly (default: warn)
 (default: warn)
  -m, --packageManager <name>  npm (default) or bower (default: npm)
  -n, --newest                 find the newest versions available instead of the latest stable versions
  -o, --optional               check only optionalDependencies
  --packageData                include stringified package file (use stdin instead)
  --packageFile <filename>     package file location (default: ./package.json)
  --packageFileDir             use same directory as packageFile to compare against installed modules. See #201.
  -p, --prod                   check only dependencies (not devDependencies)
  --peer                       check only peerDependencies
  -r, --registry <url>         specify third-party npm registry
  --configFilePath <path>      rc config file path (default: ./)
  --configFileName <path>      rc config file name (default: .ncurc.{json,yml,js})
  -s, --silent                 don't output anything (--loglevel silent)
  -t, --greatest               find the highest versions available instead of the latest stable versions
  --timeout <ms>               a global timeout in ms
  -u, --upgrade                overwrite package file
  -x, --reject <matches>       exclude packages matching the given string, comma-delimited list, or regex
  -a, --upgradeAll             include even those dependencies whose latest version satisfies the declared semver dependency
  --semverLevel <level>        find the highest version within "major" or "minor"
  --removeRange                remove version ranges from the final package version
  -v, --version                2.14.2
  -V
  -h, --help                   output usage information

查看需要更新的

$ ncu
Using D:\projects\blog\NightCat\package.json
[..................] - :
 axios          ^0.16.1  →  ^0.18.0
 connect-mongo   ^1.3.2  →   ^2.0.1
 cookie-parser   ~1.3.5  →   ~1.4.3
 debug           ~2.2.0  →   ~4.0.1
 graphql        ^0.10.0  →  ^14.0.2
 jsonwebtoken    ^7.2.1  →   ^8.3.0
 log4js          ^1.1.0  →   ^3.0.5
 mongoose        ^4.7.6  →  ^5.2.18
 nodemailer      ^2.7.0  →   ^4.6.8
 socket.io       ^1.7.2  →   ^2.1.1
 validator       ^6.2.1  →  ^10.8.0
 opn             ^4.0.2  →   ^5.4.0

The following dependencies are satisfied by their declared version range, but the installed versions are behind. You can instal
l the latest versions without modifying your package file by using npm update. If you want to update the dependencies in your p
ackage file anyway, run ncu -a.

 express-graphql   ^0.6.5  →  ^0.6.12
 markdown-it       ^8.3.1  →   ^8.4.2
 morgan            ^1.9.0  →   ^1.9.1
 qingstor          ^1.0.2  →   ^1.0.5
 qingstor-sdk     ^2.2.13  →  ^2.2.15
 uuid              ^3.0.1  →   ^3.3.2
 babel-polyfill   ^6.20.0  →  ^6.26.0
 nodemon          ^1.11.0  →  ^1.18.4

Run ncu with -u to upgrade package.json

更新全部

$ ncu -a
Using D:\projects\blog\NightCat\package.json
[..................] \ :
 axios          ^0.16.1  →  ^0.18.0
 connect-mongo   ^1.3.2  →   ^2.0.1
 cookie-parser   ~1.3.5  →   ~1.4.3
 debug           ~2.2.0  →   ~4.0.1
 graphql        ^0.10.0  →  ^14.0.2
 jsonwebtoken    ^7.2.1  →   ^8.3.0
 log4js          ^1.1.0  →   ^3.0.5
 mongoose        ^4.7.6  →  ^5.2.18
 nodemailer      ^2.7.0  →   ^4.6.8
 socket.io       ^1.7.2  →   ^2.1.1
 validator       ^6.2.1  →  ^10.8.0
 opn             ^4.0.2  →   ^5.4.0
 express-graphql   ^0.6.5  →  ^0.6.12
 markdown-it       ^8.3.1  →   ^8.4.2
 morgan            ^1.9.0  →   ^1.9.1
 qingstor          ^1.0.2  →   ^1.0.5
 qingstor-sdk     ^2.2.13  →  ^2.2.15
 uuid              ^3.0.1  →   ^3.3.2
 babel-polyfill   ^6.20.0  →  ^6.26.0
 nodemon          ^1.11.0  →  ^1.18.4
Upgraded D:\projects\blog\NightCat\package.json

npm-check-updates升级插件,更新后会自动修改package.json里的版本号,简单方便。

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 200,667评论 5 472
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,361评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 147,700评论 0 333
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,027评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,988评论 5 361
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,230评论 1 277
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,705评论 3 393
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,366评论 0 255
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,496评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,405评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,453评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,126评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,725评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,803评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,015评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,514评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,111评论 2 341

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 171,287评论 25 707
  • 用两张图告诉你,为什么你的 App 会卡顿? - Android - 掘金 Cover 有什么料? 从这篇文章中你...
    hw1212阅读 12,674评论 2 59
  • 前言 近期在项目中准备更新一下npm依赖包,可一尝试,惊了!批量更新还真麻烦。各种包要挨个更新,就算直接更改pac...
    MrXQ阅读 2,274评论 2 4
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,566评论 18 139
  • 这是我的读书笔记,阅读书籍为《关键20小时》 这本书还有个抓人眼球的副标题——【快速学会任何技能】。 其实我好久前...
    李欣哲阅读 829评论 1 12