npm更新模块并同步到package.json中

npm更新模块并同步到package.json中

使用原始npm
1.查看需要更新的版本

outdated```
1
2
3
4
5
该命令会列出所有需要更新的项目

2.修改package.json中需要更新的包对应的版本号

```npm update

由于npm update只能按照package.json中指定的版本号进行更新,太繁琐复杂,接下来使用插件更新

使用

1
2
3
1.安装

```npm install -g npm-check-updates

2.查看需要更新的版本

1
2
3
可以简写为ncu,该命令会列出需要更新的包。

3.更新

ncu -a

1
2
3
4
5
6
7
8

更新包的同时更新package.json文件


<!-- more -->


-------

zikong@zikongdeiMac kongdezhi % npm install -g npm-check-updates

/usr/local/bin/ncu -> /usr/local/lib/node_modules/npm-check-updates/bin/ncu
/usr/local/bin/npm-check-updates -> /usr/local/lib/node_modules/npm-check-updates/bin/npm-check-updates

  • npm-check-updates@4.1.2
    added 235 packages from 91 contributors in 36.495s
    zikong@zikongdeiMac kongdezhi % npm-check-updates

Checking /Users/zikong/Documents/Myblog/kongdezhi/package.json
[====================] 30/30 100%

gulp-imagemin ^6.0.0 → ^7.1.0
hexo ^3.9.0 → ^4.2.0
hexo-blog-encrypt ^2.2.7 → ^3.0.12
hexo-deployer-git ^1.0.0 → ^2.1.0
hexo-generator-archive ^0.1.5 → ^1.0.0
hexo-generator-category ^0.1.3 → ^1.0.0
hexo-generator-index ^0.2.1 → ^1.0.0
hexo-generator-searchdb ^1.0.8 → ^1.3.0
hexo-generator-sitemap ^1.2.0 → ^2.0.0
hexo-generator-tag ^0.2.0 → ^1.0.0
hexo-renderer-ejs ^0.3.1 → ^1.0.0
hexo-renderer-marked ^1.0.1 → ^2.0.0
hexo-renderer-stylus ^0.3.3 → ^1.1.0
hexo-server ^0.3.3 → ^1.0.0
leancloud-storage ^3.15.0 → ^4.5.3
valine ^1.3.9 → ^1.4.9
@babel/core ^7.5.5 → ^7.9.0

Run ncu -u to upgrade package.json
zikong@zikongdeiMac kongdezhi % ncu -u
Upgrading /Users/zikong/Documents/Myblog/kongdezhi/package.json
[====================] 30/30 100%

gulp-imagemin ^6.0.0 → ^7.1.0
hexo ^3.9.0 → ^4.2.0
hexo-blog-encrypt ^2.2.7 → ^3.0.12
hexo-deployer-git ^1.0.0 → ^2.1.0
hexo-generator-archive ^0.1.5 → ^1.0.0
hexo-generator-category ^0.1.3 → ^1.0.0
hexo-generator-index ^0.2.1 → ^1.0.0
hexo-generator-searchdb ^1.0.8 → ^1.3.0
hexo-generator-sitemap ^1.2.0 → ^2.0.0
hexo-generator-tag ^0.2.0 → ^1.0.0
hexo-renderer-ejs ^0.3.1 → ^1.0.0
hexo-renderer-marked ^1.0.1 → ^2.0.0
hexo-renderer-stylus ^0.3.3 → ^1.1.0
hexo-server ^0.3.3 → ^1.0.0
leancloud-storage ^3.15.0 → ^4.5.3
valine ^1.3.9 → ^1.4.9
@babel/core ^7.5.5 → ^7.9.0

Run npm install to install new versions.

zikong@zikongdeiMac kongdezhi % cnpm install
⠹ [9/30] Installing hexo-generator-index@^1.0.0[hexo-asset-image@https://github.com/CodeFalling/hexo-asset-image] install hexo-asset-image from git git+https://github.com/CodeFalling/hexo-asset-image.git, may be very slow, please keep patience
⠦ [17/30] Installing utils-merge@1.0.1[npminstall:runscript] hexo-blog-encrypt@3.0.12hexo-fs@1.0.2chokidar@2.1.8 › fsevents@^1.2.7 found binding.gyp file, auto run “node-gyp rebuild”, root: “/Users/zikong/Documents/Myblog/kongdezhi/node_modules/_fsevents@1.2.12@fsevents”
⠴ [27/30] Installing @types/node@* SOLINK_MODULE(target) Release/.node
⠧ [28/30] Installing safe-buffer@~5.2.0 CXX(target) Release/obj.target/fse/fsevents.o
⠏ [28/30] Installing delayed-stream@~1.0.0 SOLINK_MODULE(target) Release/fse.node
✔ Installed 30 packages
✔ Linked 722 latest versions
[1/5] scripts.postinstall hexo-renderer-ejs@1.0.0 › ejs@^2.6.1 run “node ./postinstall.js”, root: “/Users/zikong/Documents/Myblog/kongdezhi/node_modules/_ejs@2.7.4@ejs”
Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)

[1/5] scripts.postinstall hexo-renderer-ejs@1.0.0 › ejs@^2.6.1 finished in 124ms
[2/5] scripts.postinstall gulp-imagemin@7.1.0imagemin-mozjpeg@8.0.0 › mozjpeg@^6.0.0 run “node lib/install.js”, root: “/Users/zikong/Documents/Myblog/kongdezhi/node_modules/_mozjpeg@6.0.1@mozjpeg”
✔ mozjpeg pre-build test passed successfully
[2/5] scripts.postinstall gulp-imagemin@7.1.0imagemin-mozjpeg@8.0.0 › mozjpeg@^6.0.0 finished in 2s
[3/5] scripts.postinstall gulp-imagemin@7.1.0imagemin-gifsicle@7.0.0 › gifsicle@^5.0.0 run “node lib/install.js”, root: “/Users/zikong/Documents/Myblog/kongdezhi/node_modules/_gifsicle@5.0.0@gifsicle”
✔ gifsicle pre-build test passed successfully
[3/5] scripts.postinstall gulp-imagemin@7.1.0imagemin-gifsicle@7.0.0 › gifsicle@^5.0.0 finished in 1s
[4/5] scripts.postinstall gulp-imagemin@7.1.0imagemin-optipng@7.1.0 › optipng-bin@^6.0.0 run “node lib/install.js”, root: “/Users/zikong/Documents/Myblog/kongdezhi/node_modules/_optipng-bin@6.0.0@optipng-bin”
✔ optipng pre-build test passed successfully
[4/5] scripts.postinstall gulp-imagemin@7.1.0imagemin-optipng@7.1.0 › optipng-bin@^6.0.0 finished in 2s
[5/5] scripts.postinstall babel-preset-env@1.7.0babel-plugin-check-es2015-constants@6.22.0babel-runtime@6.26.0 › core-js@^2.4.0 run “node -e \”try{require(‘./postinstall’)}catch(e){}\””, root: “/Users/zikong/Documents/Myblog/kongdezhi/node_modules/_core-js@2.6.11@core-js”
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:

https://opencollective.com/core-js
https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

[5/5] scripts.postinstall babel-preset-env@1.7.0babel-plugin-check-es2015-constants@6.22.0babel-runtime@6.26.0 › core-js@^2.4.0 finished in 58ms
✔ Run 5 scripts
deprecate hexo-blog-encrypt@3.0.12hexo-fs@1.0.2 › chokidar@^2.0.4 Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
deprecate hexo-blog-encrypt@3.0.12hexo-fs@1.0.2chokidar@2.1.8 › fsevents@^1.2.7 fsevents 1 will break on node v14+. Upgrade to fsevents 2 with massive improvements.
deprecate babel-preset-env@1.7.0babel-plugin-check-es2015-constants@6.22.0babel-runtime@6.26.0 › core-js@^2.4.0 core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
Recently updated (since 2020-04-18): 12 packages (detail see file /Users/zikong/Documents/Myblog/kongdezhi/node_modules/.recently_updates.txt)
Today:
babel-preset-env@1.7.0browserslist@3.2.8 › electron-to-chromium@^1.3.47(1.3.418) (12:02:35)
✔ All packages installed (874 packages installed from npm registry, 1 packages installed from git, used 27s(network 22s), speed 746.06kB/s, json 740(1.46MB), tarball 14.46MB)

`

0%