使用npm更新已有模块

安装npm-check-updates 模块升级插件

```
npm install -g npm-check-updates
或者
cnpm install -g npm-check-updates

查看安装版本:

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

查看ncu的帮助

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 if 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 # 查看更新
 redux          ^3.7.2 ^4.0.0 
 autoprefixer   ^6.5.3 ^8.6.5 
 babel-eslint   ^7.1.1 ^8.2.6 
 eslint        ^4.11.0 ^5.1.0 
ncu -a # 更新

npm update,只能按照package.json中标注的版本号进行更新,升级后不会修改package.json中的版本号,需要自己手动修改,比较麻烦。
npm-check-updates 升级插件升级后会自动修改package.json里的版本号,简单方便。

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值