Interactive CLI utility to easily update outdated NPM dependencies with changelogs inspection support.
If you are tired of manually upgrading package.json
every time your package dependencies are getting out of date then this utility is for you.
Take a look at this demo:
First, install Node.js (at least v10.19
).
Then install this utility as global npm-module:
npm i -g npm-upgrade
This utility is supposed to be run in the root directory of your Node.js project (that contains package.json
).Run npm-upgrade --help
to see all available top-level commands:
check [filter] Check for outdated modules
ignore <command> Manage ignored modules
changelog <moduleName> Show changelog for a module
Run npm-upgrade <command> --help
to see usage help for corresponding command.check
is the default command and can be omitted so running npm-upgrade [filter]
is the same as npm-upgrade check [filter]
.
check
commandIt will find all your outdated deps and will ask to updated their versions in package.json
, one by one.For example, here is what you will see if you use outdated version of @angular/common
module:
Update "@angular/common" in package.json from 2.4.8 to 2.4.10? (Use arrow keys)
❯ Yes
No
Show changelog
Ignore
Finish update process
Yes
will update @angular/common
version in package.json
to 2.4.10
, but not immediately (see explanation below)No
will not update this module version.Show changelog
will try to find changelog url for the current module and open it in default browser.Ignore
will add this module to the ignored list (see details in Ignoring module
section below).Finish update process
will ...hm... finish update process and save all the changes to package.json
.A note on saving changes to package.json
: when you choose Yes
to update some module's version, package.json
won't be immediately updated. It will be updated only after you will process all the outdated modules and confirm update or when you choose Finish update process
. So if in the middle of the update process you've changed your mind just press Ctrl+C
and package.json
will remain untouched.
If you want to check only some deps, you can use filter
argument:
# Will check only `babel-core` module:
npm-upgrade babel-core
# Will check all the deps with `babel` in the name:
npm-upgrade '*babel*'
# Note quotes around `filter`. They are necessary because without them bash may interpret `*` as wildcard character.
# Will check all the deps, excluding any with `babel` in the name:
npm-upgrade '!*babel*'
# You can combine including and excluding rules:
npm-upgrade '*babel* !babel-transform-* !babel-preset-*'
If you want to check only a group of deps use these options:
-p, --production Check only "dependencies"
-d, --development Check only "devDependencies"
-o, --optional Check only "optionalDependencies"
Sometimes you just want to ignore newer versions of some dependency for some reason. For example, you use jquery v2
because of the old IE support and don't want npm-upgrade
to suggest you updating it to v3
. Or you use some-funky-module@6.6.5
and know that the new version 6.6.6
contains a bug that breaks your app.
You can handle these situations by ignoring such modules. You can do it in two ways: choosing Ignore
during update process or using npm ignore add
command.
You will asked two questions. First is a version range to ignore. It should be a valid semver version. Here are a few examples:
6.6.6
- will ignore only version 6.6.6
. When the next version after 6.6.6
will be published npm-upgrade
will suggest to update it. Can be used in some-funky-module
example above.>2
- will ignore all versions starting from 3.0.0
. Can be used in jquery v2
example above.6.6.x || 6.7.x
- will ignore all 6.6.x
and 6.7.x
versions.*
- will ignore all new versions.And after that npm-upgrade
will ask about the ignore reason. The answer is optional but is strongly recommended because it will help to explain your motivation to your сolleagues and to yourself after a few months.
All the data about ignored modules will be stored in .npm-upgrade.json
file next to your project's package.json
.
ignore
commandIt will help you manage ignored modules. See Ignoring module section for more details.It has the following subcommands:
npm-upgrade ignore <command>
Commands:
add [module] Add module to ignored list
list Show the list of ignored modules
reset [modules...] Reset ignored modules
add
- will add a module from your deps to ignored list. You can either provide module name as optional module
argument or interactively select it from the list of project's deps.list
- will show the list of currently ignored modules along with their ignored versions and reasons.reset
- will remove modules from the ignored list. You can either provide module names as modules
argument (separated by space) or interactively select them from the list of project's deps.changelog
commandnpm-upgrade changelog <moduleName>
Will try to find changelog url for provided module and open it in default browser.
Wrong changelog shown for <moduleName> or not shown at all!
Yes, It can happen sometimes. This is because there is no standardized way to specify changelog location for the module, so it tries to guess it, using these rules one by one:
db/changelogUrls.json
from master
branch on GitHub or the local copy if it's unreachable.changelog
field from module's package.json
.repository.url
field and if it's on GitHub, try to request some common changelog files (CHANGELOG.md
, History.md
etc.) from master
branch and if it fails, open Releases
page.So, if it guessed wrong it would be great if you could either fill an issue about this or submit a PR which adds proper changelog URL to db/changelogUrls.json
. There is a tool in the repository for you to make it as easy as possible:
./tools/addModuleChangelogUrlToDb.js <moduleName> <changelogUrl>
npm update常用命令使用 一、更新 npm-check检查更新 npm install -g npm-check npm-check 2. npm-upgrade更新 npm install -g npm-upgrade npm-upgrade 3. 更新全局包: npm update -g 4. 更新生产环境依赖包:
Bump a package version npm version [ | major | minor | patch | premajor | preminor | prepatch | prerelease [–preid=] | from-git] ‘npm [-v | --version]’ to print npm version ‘npm view version’ to view
1. babel-upgrade 官方的介绍是这样的 一个工具,可以更新大多数使用babel的依赖关系,配置文件,和JavaScript文件(将来可能会更多)。 字面意思是说 使用babel-upgrade 可以快速的把你的应用从 babel 6 更新到 babel 7 2. 用法 安装环境: nodejs >=8 如果 npm<5.2 使用 npm install npx -g 安装npx 使用
Remove a package from the registry npm unpublish [<@scope>/][@] WARNING It is generally considered bad behavior to remove versions of a library that others are depending on! Consider using the depreca
1. 准备工作:npm的源如果是淘宝源,请切回官方的地址哦(是官方的此条可忽略) 2. 切回方式:采用命令nrm来切回官方源 nrm ls nrm use npm 3. 命令行登录npm官网 npm init 初始化包管理文件package.json npm init -y npm login 输入用户名和密码即可登录 npm adduser 添加npm用户信息 npm versio
三行命令,我让npm更新了十八个版本! 最近写前端,发现自己很久没碰前端了,上次写前端还是上次呢! 好,废话不多说,今天分享一下windows最官方最快的npm更新方法 以管理员身份打开powershell 依次执行以下命令 Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force npm install -g npm-windows-u
网上找个例子,运行的时候各种冲突,各种报错,折腾了快一天都没跑起来。直到遇到了神奇的npm install --legacy-peer-deps 指令才成功。记录如下: C:\workspace\vue2-happyfri>npm install npm WARN config global `--global`, `--local` are deprecated. Use `--location
问题内容: 我更新到最新的节点v9.1.0,现在npm不起作用。 npm WARN npm npm不支持Node.js v9.1.0 问题答案: 事实证明,当前安装的版本与新版本不兼容,并且很难进行更新。 解决方案是先卸载然后重新安装,其中将包含的正确版本。 这是如何做: 卸载。 从https://nodejs.org安装
1 npm的历史、现状和发展 历史 2009年,npm(Node 包管理器)初次发布早期预览版; 2011年,npm 1.0:发布; 2015年,npm 支持私有模块 现状 npm公司发布了其软件包管理工具npm 5.0版,npm 5提升了性能,使其保持了对同类软件的竞争力。 npm的出现使我们分享代码或者复用代码变得更加简单。 发展 npm作为随同node.JS一起安装的包管理工具,在node包
npm 是 Node.js 的包管理工具,用来安装各种 Node.js 的扩展。 npm 是 JavaScript 的包管理工具,也是世界上最大的软件注册表。有超过 60 万个 JavaScript 代码包可供下载,每周下载约 30 亿次。npm 让 JavaScript 开发人员可以轻松地使用其他开发人员共享的代码。 npm 由三个不同的部分组成: 网站 注册表 命令行界面(CLI) 示例:查找
Upgrade npm on Windows Upgrading npm on Windows requires manual steps to ensure that PowerShell/CMD find the new version of npm. This is a small tool made with ❤️ for npm and Node, reducing the proces
npm模块升级工具npm-check,提供命令行下的图形界面,可以手动选择升级哪些模块。 检查是否有需要更新、错误的和未使用的依赖: 功能特性: 依赖更新及时提醒 提供软件包更新接链,可以及时更新升级 友好的提示你所缺少的依赖包,减少不必要的盲目查找 支持安装在全局工作环境,via -g 平滑更新升级,via -u 支持公有域和私有域@scoped/packages 支持ES6-style 可交替
Overview Codebox npm is a serverless npm registry to allow companies that wish to keep their intellectual property. It allows sharing of npm modules within a company but additionally allows access to