使用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里的版本號,簡單方便。

?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,224評論 25 708
  • 用兩張圖告訴你,為什么你的 App 會卡頓? - Android - 掘金 Cover 有什么料? 從這篇文章中你...
    hw1212閱讀 14,048評論 2 59
  • 前言 近期在項目中準備更新一下npm依賴包,可一嘗試,驚了!批量更新還真麻煩。各種包要挨個更新,就算直接更改pac...
    MrXQ閱讀 2,598評論 2 4
  • Spring Cloud為開發(fā)人員提供了快速構建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,658評論 19 139
  • 這是我的讀書筆記,閱讀書籍為《關鍵20小時》 這本書還有個抓人眼球的副標題——【快速學會任何技能】。 其實我好久前...
    李欣哲閱讀 922評論 1 12

友情鏈接更多精彩內(nèi)容