Repository: raineorshine/npm-check-updates Branch: main Commit: cf1001bed2d5 Files: 238 Total size: 755.2 KB Directory structure: gitextract_0r1ho66r/ ├── .editorconfig ├── .eslintrc.js ├── .gitattributes ├── .github/ │ ├── CONTRIBUTING.md │ ├── ISSUE_TEMPLATE/ │ │ └── bug_report.md │ └── workflows/ │ ├── codeql.yml │ ├── lint.yml │ ├── release.yml │ └── test.yml ├── .gitignore ├── .hooks/ │ ├── post-commit │ └── pre-push ├── .markdownlint.js ├── .ncurc.js ├── .npmrc ├── .prettierignore ├── .prettierrc.json ├── .vscode/ │ └── settings.json ├── CHANGELOG.md ├── Dockerfile ├── LICENSE ├── README.md ├── deploy.md ├── package.json ├── src/ │ ├── bin/ │ │ └── cli.ts │ ├── cli-options.ts │ ├── index.ts │ ├── lib/ │ │ ├── cache.ts │ │ ├── chalk.ts │ │ ├── defineConfig.ts │ │ ├── determinePackageManager.ts │ │ ├── doctor.ts │ │ ├── exists.ts │ │ ├── figgy-pudding/ │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ └── index.js │ │ ├── filterAndReject.ts │ │ ├── filterObject.ts │ │ ├── findLockfile.ts │ │ ├── findPackage.ts │ │ ├── getAllPackages.ts │ │ ├── getCurrentDependencies.ts │ │ ├── getEnginesNodeFromRegistry.ts │ │ ├── getIgnoredUpgradesDueToEnginesNode.ts │ │ ├── getIgnoredUpgradesDueToPeerDeps.ts │ │ ├── getInstalledPackages.ts │ │ ├── getNcuRc.ts │ │ ├── getPackageJson.ts │ │ ├── getPackageManager.ts │ │ ├── getPackageVersion.ts │ │ ├── getPeerDependenciesFromRegistry.ts │ │ ├── getPreferredWildcard.ts │ │ ├── getRepoUrl.ts │ │ ├── initOptions.ts │ │ ├── isUpgradeable.ts │ │ ├── keyValueBy.ts │ │ ├── libnpmconfig/ │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ └── index.js │ │ ├── loadPackageInfoFromFile.ts │ │ ├── logging.ts │ │ ├── mergeOptions.ts │ │ ├── parseCooldown.ts │ │ ├── pick.ts │ │ ├── programError.ts │ │ ├── queryVersions.ts │ │ ├── resolveDepSections.ts │ │ ├── runGlobal.ts │ │ ├── runLocal.ts │ │ ├── sortBy.ts │ │ ├── spawnCommand.ts │ │ ├── table.ts │ │ ├── upgradeDependencies.ts │ │ ├── upgradeJsonCatalogDependencies.ts │ │ ├── upgradePackageData.ts │ │ ├── upgradePackageDefinitions.ts │ │ ├── upgradeYamlCatalogDependencies.ts │ │ ├── utils/ │ │ │ └── parseJson.ts │ │ ├── version-util.ts │ │ └── wrap.ts │ ├── package-managers/ │ │ ├── README.md │ │ ├── bun.ts │ │ ├── filters.ts │ │ ├── gitTags.ts │ │ ├── index.ts │ │ ├── npm.ts │ │ ├── pnpm.ts │ │ ├── staticRegistry.ts │ │ └── yarn.ts │ ├── scripts/ │ │ ├── build-options.ts │ │ └── install-hooks │ └── types/ │ ├── CLIOption.ts │ ├── Cacher.ts │ ├── CatalogConfig.ts │ ├── CooldownFunction.ts │ ├── DependencyGroup.ts │ ├── ExtendedHelp.ts │ ├── FilterFunction.ts │ ├── FilterPattern.ts │ ├── FilterResultsFunction.ts │ ├── GetVersion.ts │ ├── GroupFunction.ts │ ├── IgnoredUpgradeDueToEnginesNode.ts │ ├── IgnoredUpgradeDueToPeerDeps.ts │ ├── IndexType.ts │ ├── Maybe.ts │ ├── MockedVersions.ts │ ├── NpmConfig.ts │ ├── NpmOptions.ts │ ├── Options.ts │ ├── PackageFile.ts │ ├── PackageFileRepository.ts │ ├── PackageInfo.ts │ ├── PackageManager.ts │ ├── PackageManagerName.ts │ ├── Packument.ts │ ├── RcOptions.ts │ ├── RunOptions.json │ ├── RunOptions.ts │ ├── SpawnOptions.ts │ ├── SpawnPleaseOptions.ts │ ├── StaticRegistry.ts │ ├── Target.ts │ ├── TargetFunction.ts │ ├── UpgradeGroup.ts │ ├── Version.ts │ ├── VersionLevel.ts │ ├── VersionResult.ts │ ├── VersionSpec.ts │ ├── libnpmconfig.d.ts │ └── prompts-ncu.d.ts ├── tea.yaml ├── test/ │ ├── bin.test.ts │ ├── bun/ │ │ ├── bun.lockb │ │ ├── index.test.ts │ │ └── package.json │ ├── bun-install.sh │ ├── cache.test.ts │ ├── cli-options.test.ts │ ├── cooldown.test.ts │ ├── deep.test.ts │ ├── dep.test.ts │ ├── determinePackageManager.test.ts │ ├── doctor.test.ts │ ├── e2e/ │ │ ├── cjs/ │ │ │ ├── index.js │ │ │ └── package.json │ │ └── esm/ │ │ ├── index.js │ │ └── package.json │ ├── e2e.sh │ ├── enginesNode.test.ts │ ├── filter.test.ts │ ├── filterResults.test.ts │ ├── filterVersion.test.ts │ ├── format.test.ts │ ├── getAllPackages.test.ts │ ├── getCurrentDependencies.test.ts │ ├── getEnginesNodeFromRegistry.test.ts │ ├── getIgnoredUpgradesDueToEnginesNode.test.ts │ ├── getIgnoredUpgradesDueToPeerDeps.test.ts │ ├── getInstalledPackages.test.ts │ ├── getPeerDependenciesFromRegistry.test.ts │ ├── getPreferredWildcard.test.ts │ ├── getRepoUrl.test.ts │ ├── github-urls.test.ts │ ├── global.test.ts │ ├── group.test.ts │ ├── helpers/ │ │ ├── chaiSetup.ts │ │ ├── doctorHelpers.ts │ │ ├── removeDir.ts │ │ └── stubVersions.ts │ ├── index.test.ts │ ├── install.test.ts │ ├── interactive.test.ts │ ├── isUpgradeable.test.ts │ ├── package-managers/ │ │ ├── deno/ │ │ │ └── index.test.ts │ │ ├── npm/ │ │ │ ├── index.test.ts │ │ │ └── package.json │ │ └── yarn/ │ │ ├── default/ │ │ │ └── package.json │ │ ├── index.test.ts │ │ ├── nolockfile/ │ │ │ └── package.json │ │ └── v4/ │ │ └── package.json │ ├── parseJson.test.ts │ ├── peer.test.ts │ ├── queryVersions.test.ts │ ├── rc-config.test.ts │ ├── registryType.test.ts │ ├── rejectVersion.ts │ ├── target.test.ts │ ├── test-data/ │ │ ├── basic/ │ │ │ └── package.json │ │ ├── deep-ncurc/ │ │ │ ├── .ncurc.js │ │ │ ├── package.json │ │ │ └── pkg/ │ │ │ ├── sub1/ │ │ │ │ ├── .ncurc.js │ │ │ │ └── package.json │ │ │ ├── sub2/ │ │ │ │ ├── .ncurc.js │ │ │ │ ├── package.json │ │ │ │ ├── sub21/ │ │ │ │ │ ├── .ncurc.js │ │ │ │ │ └── package.json │ │ │ │ └── sub22/ │ │ │ │ └── package.json │ │ │ └── sub3/ │ │ │ ├── package.json │ │ │ ├── sub31/ │ │ │ │ ├── .ncurc.js │ │ │ │ └── package.json │ │ │ └── sub32/ │ │ │ └── package.json │ │ ├── doctor/ │ │ │ ├── custominstall/ │ │ │ │ └── package.json │ │ │ ├── customtest/ │ │ │ │ └── package.json │ │ │ ├── customtest2/ │ │ │ │ ├── echo.js │ │ │ │ └── package.json │ │ │ ├── fail/ │ │ │ │ ├── README.md │ │ │ │ ├── package.json │ │ │ │ └── test.js │ │ │ ├── nolockfile/ │ │ │ │ └── package.json │ │ │ ├── nopackagefile/ │ │ │ │ └── nil │ │ │ ├── notestscript/ │ │ │ │ └── package.json │ │ │ ├── options/ │ │ │ │ ├── package.json │ │ │ │ └── test.js │ │ │ └── pass/ │ │ │ ├── README.md │ │ │ └── package.json │ │ ├── ncu/ │ │ │ ├── package-large.json │ │ │ ├── package.json │ │ │ └── package2.json │ │ ├── peer-post-upgrade/ │ │ │ └── package.json │ │ ├── peer-post-upgrade-no-upgrades/ │ │ │ └── package.json │ │ ├── registry.json │ │ ├── workspace-basic/ │ │ │ ├── package.json │ │ │ └── pkg/ │ │ │ └── sub/ │ │ │ └── package.json │ │ ├── workspace-no-sub-packages/ │ │ │ └── package.json │ │ ├── workspace-sub-package-names/ │ │ │ ├── package.json │ │ │ └── pkg/ │ │ │ ├── dirname-does-not-match-name/ │ │ │ │ └── package.json │ │ │ ├── dirname-matches-name/ │ │ │ │ └── package.json │ │ │ ├── dirname-will-become-name/ │ │ │ │ └── package.json │ │ │ └── unlisted/ │ │ │ └── package.json │ │ └── workspace-workspace-param-is-array/ │ │ └── package.json │ ├── timeout.test.ts │ ├── upgradeDependencies.test.ts │ ├── upgradeYamlCatalogDependencies.test.ts │ ├── version-util.test.ts │ └── workspaces.test.ts ├── tsconfig.json └── vite.config.mts ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ # editorconfig.org root = true [*] indent_style = space indent_size = 2 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.{md,jade}] trim_trailing_whitespace = false ================================================ FILE: .eslintrc.js ================================================ module.exports = { env: { es6: true, mocha: true, node: true, }, extends: ['standard', 'eslint:recommended', 'plugin:import/typescript', 'raine', 'prettier'], overrides: [ { files: ['**/*.ts'], parser: '@typescript-eslint/parser', parserOptions: { ecmaVersion: 2018, sourceType: 'module', project: './tsconfig.json', }, extends: ['plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended'], globals: { Atomics: 'readonly', SharedArrayBuffer: 'readonly', }, plugins: ['@typescript-eslint'], rules: { '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-non-null-assertion': 'off', '@typescript-eslint/no-use-before-define': 'error', '@typescript-eslint/no-unused-vars': [ 'error', { caughtErrors: 'none', // using destructuring to omit properties from objects destructuredArrayIgnorePattern: '^_', argsIgnorePattern: '^_', varsIgnorePattern: '^_', }, ], '@typescript-eslint/array-type': [ 'error', { default: 'array', }, ], }, }, ], plugins: ['jsdoc'], rules: { 'jsdoc/require-jsdoc': [ 'error', { contexts: ['VariableDeclarator > ArrowFunctionExpression'], require: { ClassDeclaration: true, ClassExpression: true, }, }, ], }, } ================================================ FILE: .gitattributes ================================================ # Enforce Unix newlines * text=auto eol=lf ================================================ FILE: .github/CONTRIBUTING.md ================================================ ## Filing an issue Make sure you read the list of [known issues](https://github.com/raineorshine/npm-check-updates#known-issues) and search for [similar issues](https://github.com/raineorshine/npm-check-updates/issues) before filing an issue. ## Known Issues - If `ncu` prints output that does not seem related to this package, it may be conflicting with another executable such as `ncu-weather-cli` or Nvidia CUDA. Try using the long name instead: `npm-check-updates`. - Windows: If npm-check-updates hangs, try setting the package file explicitly: `ncu --packageFile package.json`. You can run `ncu --loglevel verbose` to confirm that it was incorrectly waiting for stdin. See [#136](https://github.com/raineorshine/npm-check-updates/issues/136#issuecomment-155721102). When filing an issue, please include: - node version - npm version - npm-check-updates version - the relevant package names and their specified versions from your package file - ...or the output from `npm -g ls --depth=0` if using global mode ## Executable Stack Trace The Vite Build uses SSR to bundle all dependencies for efficiency. There currently is no source map for `./build/cli.js`. To execute npm-check-updates with an accurate stack trace run the following ```sh git clone https://github.com/raineorshine/npm-check-updates /MY_PROJECTS npx tsx /MY_PROJECTS/npm-check-updates/src/bin/cli.ts ``` ## Design Guidelines The _raison d'être_ of npm-check-updates is to upgrade package.json dependencies to the latest versions, ignoring specified versions. Suggested features that do not fit within this objective will be considered out of scope. npm-check-updates maintains a balance between minimalism and customizability. The default execution with no options will always produce simple, clean output. If you would like to add additional information to ncu's output, you may propose a new value for the `--format` option. ## Adding a new CLI or module option All of ncu's options are generated from [/src/cli-options.ts](https://github.com/raineorshine/npm-check-updates/blob/main/src/cli-options.ts). You can add a new option to this file and then run `npm run build` to automatically generate README, CLI help text, and TypeScript definitions. ================================================ FILE: .github/ISSUE_TEMPLATE/bug_report.md ================================================ --- name: Bug report about: Create a report to help us improve title: '' labels: '' assignees: '' --- - [] I have searched for [similar issues](https://github.com/raineorshine/npm-check-updates/issues) --- ## Steps to Reproduce .ncurc: ```js ``` Dependencies: ```json ``` Steps: ## Current Behavior ## Expected Behavior ================================================ FILE: .github/workflows/codeql.yml ================================================ name: 'CodeQL' on: push: branches: - main - '!dependabot/**' pull_request: # The branches below must be a subset of the branches above branches: - main schedule: - cron: '0 2 * * 5' jobs: analyze: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read security-events: write steps: - name: Checkout repository uses: actions/checkout@v3 - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: languages: 'javascript' - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 ================================================ FILE: .github/workflows/lint.yml ================================================ name: Lint on: push: branches: - main - '!dependabot/**' pull_request: branches: - '**' env: FORCE_COLOR: 2 NODE: 24 permissions: contents: read jobs: lint: runs-on: ubuntu-latest steps: - name: Clone repository uses: actions/checkout@v3 - name: Set up Node.js uses: actions/setup-node@v3 with: node-version: ${{ env.NODE }} cache: npm - name: Install npm dependencies run: npm ci - name: Run lint run: npm run lint ================================================ FILE: .github/workflows/release.yml ================================================ name: Release on: push: tags: - 'v*' jobs: release: name: Release runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v5 - name: Release uses: softprops/action-gh-release@v2 with: generate_release_notes: true ================================================ FILE: .github/workflows/test.yml ================================================ name: Tests on: push: branches: - main - '!dependabot/**' pull_request: branches: - '**' env: FORCE_COLOR: 2 permissions: contents: read jobs: run: permissions: contents: read # for actions/checkout to fetch code name: Node ${{ matrix.node }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: node: [20, 22] os: [ubuntu-latest, windows-latest] steps: - name: Clone repository uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} cache: npm - name: Enable corepack run: corepack enable - name: Install npm dependencies run: npm ci - name: Build run: npm run build - name: Unit Tests run: npm run test:unit - name: Bun Tests run: npm run test:bun - name: E2E Tests run: npm run test:e2e if: startsWith(matrix.os, 'ubuntu') && matrix.node == 20 ================================================ FILE: .gitignore ================================================ lib-cov *.seed *.log *.csv *.dat *.out *.pid *.gz pids logs results npm-debug.log node_modules build .idea *.iml yarn.lock .DS_store # test files /test/temp_package*.json /test/.ncurc.json # Agent files .claude ================================================ FILE: .hooks/post-commit ================================================ #!/usr/bin/env bash SHORT_SHA=$(git rev-parse HEAD) LINT_LOG="$TMPDIR"/lint."$SHORT_SHA".log # strip color strip() { sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" } # display a notification notify() { # if osascript is not supported, do nothing if [ -f /usr/bin/osascript ]; then # read back in the lint errors ERRORS=$(sed 1,4d "$LINT_LOG") # Trigger apple- or OSA-script on supported platforms /usr/bin/osascript -e "display notification \"$ERRORS\" with title \"$*\"" fi # clean up rm "$LINT_LOG" } # ensure failed lint exit code passes through sed set -o pipefail # Do NOT run this when rebasing or we can't get the branch branch=$(git branch --show-current) if [ -z "$branch" ]; then exit 0 fi # Lint in the background, not blocking the terminal and piping all output to a file. # If the lint fails, trigger a notification (on supported platforms) with at least the first error shown. # We pipe output so that the terminal (tmux, vim, emacs etc.) isn't borked by stray output. npm run lint:src | strip &>"$LINT_LOG" || notify "Lint Error" & ================================================ FILE: .hooks/pre-push ================================================ #!/bin/sh fail=0 npm run lint || fail=1 npm run prettier -- --check || fail=1 if [ "$fail" -ne 0 ]; then exit 1 fi ================================================ FILE: .markdownlint.js ================================================ module.exports = { // use code indentation rather than code fencing so that extended help can be used for both the CLI and README 'code-block-style': 0, 'first-line-heading': 0, 'line-length': 0, 'no-bare-urls': 0, 'no-duplicate-heading': { siblings_only: true, }, // inline HTML used to create tables without headers 'no-inline-html': 0, 'commands-show-output': 0, } ================================================ FILE: .ncurc.js ================================================ module.exports = { format: 'group', reject: [ // breaking 'eslint', 'eslint-plugin-n', 'eslint-plugin-promise', // esm only modules '@types/chai', '@types/chai-as-promised', '@types/remote-git-tags', 'camelcase', 'chai-as-promised', 'find-up', 'chai', 'p-map', 'remote-git-tags', 'untildify', ], } ================================================ FILE: .npmrc ================================================ script-shell = bash ================================================ FILE: .prettierignore ================================================ build/ ================================================ FILE: .prettierrc.json ================================================ { "arrowParens": "avoid", "importOrder": ["^\\.\\./", "^\\./"], "importOrderSortSpecifiers": true, "overrides": [{ "files": "*.ts", "options": { "parser": "typescript" } }], "plugins": ["@trivago/prettier-plugin-sort-imports"], "printWidth": 120, "semi": false, "singleQuote": true, "tabWidth": 2, "trailingComma": "all", "useTabs": false } ================================================ FILE: .vscode/settings.json ================================================ { "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true } ================================================ FILE: CHANGELOG.md ================================================ # Changelog This file only documents **major version** releases. For smaller releases, you're stuck reading the [commit history](https://github.com/raineorshine/npm-check-updates/commits/main). ## [18.0.0] - 2025-04-21 ### Breaking The **only** breaking change in v18 is with the `-g/--global` flag. `npm-check-updates -g` will now auto-detect your package manager based on the execution path. Previously, it defaulted to `npm`. - `yarn dlx ncu -g --packageManager yarn` → `yarn dlx ncu -g` - `pnpm dlx ncu --global --packageManager pnpm` → `pnpm dlx ncu -g` - `bunx ncu -g--packageManager pnpm` → `bunx ncu -g` If for some reason you were running `ncu -g` with an alternative package manager and relying on it checking the global `npm` packages, you will need to now explicitly specify npm: - `ncu -g` → `ncu -g--packageManager npm` Thanks to @LuisFerLCC for the improvement (#1514). ## [17.0.0] - 2024-07-31 ### Breaking - Require node >= 18.18.0 - Deprecated versions are no longer excluded by default, as it requires fetching package info for every published version, significantly slowing down upgrades. - You can opt in with `--no-deprecated` in the CLI or `deprecated: false` in your `ncurc` config. - In workspaces mode, `--root` is now set by default (#1353) - To **not** check the root package.json, use `--no-root`. - If you have a [packageManager](https://nodejs.org/api/packages.html#packagemanager) field in your package.json, it is now upgraded by default (#1390) - Use `--dep prod,dev,optional` for the old behavior. ## [16.0.0] - 2022-07-23 ### Breaking - Automatic detection of package data on stdin has been removed. This feature was deprecated in `v14.0.0`. Add `--stdin` for old behavior. - Wild card filters now apply to scoped packages. Previously, `ncu -f '*vite*'` would not include `@vitejs/plugin-react`. Now, filters will match any part of the package name, including the scope. Use a more specific glob or regex expression for old behavior. ## [15.0.0] - 2022-06-30 ### Breaking - node >= 14.14 is now required (#1145) - Needed to upgrade `update-notifier` with has a moderate severity vulnerability - yarn autodetect has been improved (#1148) - This is a patch, though _technically_ it is breaking. In the obscure case where `--packageManager` is not given, there is no `package-lock.json` in the current folder, and there is a `yarn.lock` in an ancestor directory, npm-check-updates will now use yarn. - More practically, if you needed to specify `--packageManager yarn` explicitly before, you may not have to now ## [14.0.0] - 2022-06-16 ### Breaking Prerelease versions are now "upgraded" to versions with a different [preid](https://docs.npmjs.com/cli/v8/commands/npm-version#preid). For example, if you have a dependency at `1.3.3-next.1` and the version fetched by ncu is `1.2.3-dev.2`, ncu **will** suggest an "upgrade" to `1.2.3-dev.2`. This is because prerelease versions with different preids are incomparable. Since they are incomparable, ncu now assumes the fetched version is desired. Since this change affects only prereleases, there is no impact on default `ncu` usage that fetches the `latest` version. With `--pre 1` or `--target newest` or `--target greatest`, this change could affect which version is suggested if versions with different preids are published. The change was made to support the new `--target @[tag]` feature. If you have a use case where this change is not what is desired, please [report an issue](https://github.com/raineorshine/npm-check-updates/issues/new). The intention is for zero disruption to current usage. ### Features - You can now upgrade to a specific tag, e.g. `--target @next`. Thanks to [IMalyugin](https://github.com/IMalyugin). ## [13.0.0] - 2022-05-15 ### Breaking - node >= 14 is now required - Several options which have long been deprecated have been removed: - `--greatest` - Instead use `--target greatest` - `--newest` - Instead use `--target newest` - `--ownerChanged` - Instead use `--format ownerChanged` - `--semverLevel` - Renamed to `--target` ## [12.0.0] - 2021-11-01 ### Breaking - node >= 12 is required. Time to upgrade that old-ass server you never touch. - `peerDependencies` are now excluded by default. Peer dependencies should use the **lowest** possible version that works. The old behavior encouraged a bad practice of upgrading peer dependencies. You can use `--dep prod,dev,optional,peer` for the old behavior ([#951](https://github.com/raineorshine/npm-check-updates/issues/951)). - Dependencies with `>` will be converted to `>=`. The old behavior was causing upgrades to `> [latest]` which was impossible ([#957](https://github.com/raineorshine/npm-check-updates/issues/957)). ## Other - TypeScript! There is a new build process, so if you have any issues with the executable or types, please report. It should be a non-breaking change if I did it correctly ([#888](https://github.com/raineorshine/npm-check-updates/issues/888)). - WHen using `npm-check-updates` as a module, `vm` (versionmanager) is no longer exported. It was previously exposed for testing purposes, but was never part of the official API. ## [11.0.0] - 2021-01-20 ### Breaking - `--packageFile` - Now interprets its argument as a glob pattern. It is possible that a previously supplied argument may be interpreted differently now (though I'm not aware of specific instances). Due to our conservative release policy we are releasing as a major version upgrade and allowing developers to assess for themselves. ### Features - `--deep` - Run recursively in current working directory. Alias of `--packageFile '**/package.json'`. See: [#785](https://github.com/raineorshine/npm-check-updates/issues/785) ## [10.0.0] - 2020-11-08 ### Breaking - Specifying both the `--filter` option and argument filters will now throw an error. Use one or the other. Previously the arguments would override the `--filter` option, which made for a confusing result when accidentally not quoting the option in the shell. This change is only breaking for those who are relying on the incorrect behavior of argument filters overriding `--filter`. See: [#759](https://github.com/raineorshine/npm-check-updates/issues/759#issuecomment-723587297) ## [9.0.0] - 2020-09-10 ### Breaking - Versions marked as `deprecated` in npm are now ignored by default. If the latest version is deprecated, the next highest non-deprecated version will be suggested. Use `--deprecated` to include deprecated versions (old behavior). ## [8.0.0] - 2020-08-29 ### Breaking - `--semverLevel major` is now `--target minor`. `--semverLevel minor` is now `--target patch`. This change was made to provide more intuitive semantics for `--semverLevel` (now `--target`). Most people assumed it meant the inclusive upper bound, so now it reflects that. [a2111f4c2](https://github.com/raineorshine/npm-check-updates/commits/a2111f4c2) - Programmatic usage: `run` now defaults to `silent: true` instead of `loglevel: 'silent`, unless `loglevel` is explicitly specified. If you overrode `silent` or `loglevel`, this may affect the logging behavior. [423e024](https://github.com/raineorshine/npm-check-updates/commits/423e024) ### Deprecated Options that controlled the target version (upper bound) of upgrades have been consolidated under `--target`. The old options are aliased with a deprecation warning and will be removed in the next major version. No functionality has been removed. - `--greatest`: Renamed to `--target greatest` - `--newest`: Renamed to `--target newest` - `--semverLevel`: Renamed to `--target` See: [7eca5bf3](https://github.com/raineorshine/npm-check-updates/commits/7eca5bf3) ### Features #### Doctor Mode [#722](https://github.com/raineorshine/npm-check-updates/pull/722) Usage: `ncu --doctor [-u] [options]` Iteratively installs upgrades and runs tests to identify breaking upgrades. Add `-u` to execute (modifies your package file, lock file, and node_modules). To be more precise: 1. Runs `npm install` and `npm test` to ensure tests are currently passing. 2. Runs `ncu -u` to optimistically upgrade all dependencies. 3. If tests pass, hurray! 4. If tests fail, restores package file and lock file. 5. For each dependency, install upgrade and run tests. 6. When the breaking upgrade is found, saves partially upgraded package.json (not including the breaking upgrade) and exits. Example: ```sh $ ncu --doctor -u npm install npm run test ncu -u npm install npm run test Failing tests found: /projects/myproject/test.js:13 throw new Error('Test failed!') ^ Now let’s identify the culprit, shall we? Restoring package.json Restoring package-lock.json npm install npm install --no-save react@16.0.0 npm run test ✓ react 15.0.0 → 16.0.0 npm install --no-save react-redux@7.0.0 npm run test ✗ react-redux 6.0.0 → 7.0.0 Saving partially upgraded package.json ``` #### GitHub URLs Added support for GitHub URLs. See: [f0aa792a4](https://github.com/raineorshine/npm-check-updates/commits/f0aa792a4) Example: ```json { "dependencies": { "chalk": "https://github.com/chalk/chalk#v2.0.0" } } ``` #### npm aliases Added support for npm aliases. See: [0f6f35c](https://github.com/raineorshine/npm-check-updates/commits/0f6f35c) Example: ```json { "dependencies": { "request": "npm:postman-request@2.88.1-postman.16" } } ``` #### Owner Changed [#621](https://github.com/raineorshine/npm-check-updates/pull/621) Usage: `ncu --ownerChanged` Check if the npm user that published the package has changed between current and upgraded version. Output values: - Owner changed: `*owner changed*` - Owner has not changed: _no output_ - Owner information not available: `*unknown*` Example: ```sh $ ncu --ownerChanged Checking /tmp/package.json [====================] 1/1 100% mocha ^7.1.0 → ^8.1.3 *owner changed* Run ncu -u to upgrade package.json ``` ### Commits ## [7.0.0] - 2020-06-09 ### Breaking - Removed bower support (4e4b47fd3bb567435b456906d0106ef442bf46fe) ### Patch - Fix use of "<" with single digit versions (f04d00e550ce606893bee77b78ef2a0b2a50246a) ### Other - Change eslint configuration - Update dependencies - Replace cint methods with native methods - Add CI via GitHub Actions workflow ## [6.0.0] - 2020-05-14 ### Breaking - `--semverLevel` now supports version ranges. This is a breaking change since version ranges are no longer ignored by `--semverLevel`, which may result in some dependencies having new suggested updates. If you are not using `--semverLevel`, NO CHANGE! 😅 ## [5.0.0] - 2020-05-11 ### Breaking ~node >= 8~ node >= 10.17 Bump minimum node version to `v10.17.0` due to `move-file` #651 If `ncu` was working for you on `v4.x`, then `v5.0.0` will still work. Just doing a major version bump since ncu's officially supported node version is changing. `v4` should be patched to be compatible with node `v8`, but I'll hold off unless someone requests it. ## [4.0.0] - 2019-12-10 ncu v3 excluded prerelease versions (`-alpha`, `-beta`, etc) from the remote by default, as publishing prerelease versions to `latest` is unconventional and not recommended. Prereleases versions can be included by specifying `--pre` (and is implied in options `--greatest` and `--newest`). However, when you are already specifying a prerelease version in your package.json dependencies, then clearly you want ncu to find newer prerelease versions. This is now default in v4, albeit with the conservative approach of sticking to the `latest` tag. ### Migration No effect for most users. If a prerelease version is published on the `latest` tag, and you specify a prerelease version in your package.json, ncu will now suggest upgrades for it. If a prerelease version is published on a different tag, there is no change from ncu v3; you will still need `--pre`, `--greatest`, or `--newest` to get prerelease upgrades. ## [3.0.0] - 2019-03-07 ### Breaking #### node < 8 deprecated The required node version has been updated to allow the use of newer JavaScript features and reduce maintenance efforts for old versions. #### System npm used In ncu v2, an internally packaged npm was used for version lookups. When this became out-of-date and differed considerably from the system npm problems would occur. In ncu v3, the system-installed npm will be used for all lookups. This comes with the maintenance cost of needing to upgrade ncu whenever the output format of npm changes. #### Installed modules ignored In ncu v2, out-of-date dependencies in package.json that were installed up-to-date (e.g. `^1.0.0` specified and `1.0.1` installed) were ignored by ncu. Installed modules are now completely ignored and ncu only consider your package.json. This change was made to better match users’ expectations. #### Existing version ranges that satisfy latest are ignored (-a by default) In ncu v2, if you had `^1.0.0` in your package.json, a newly released `1.0.1` would be ignored by ncu. The logic was that `^1.0.0` is a range that includes `1.0.1`, so you don’t really need to change the version specified in your package.json, you just need to run `npm update`. While logical, that turned out to be quite confusing to users. In ncu v3, the package.json will always be upgraded if there is a newer version (same as `-a` in v2). The old default behavior is available via the `--minimal` option. #### Prerelease versions ignored In ncu v2, any version published to the `latest` tag was assumed to be a stable release version. In practice, occasional package authors would accidentally or unconventionally publish `-alpha`, `-beta`, and `-rc` versions to the `latest` tag. While I still consider this a bad practice, ncu v3 now ignores these prerelease versions by default to better match users’ expectations. The old behavior is available via the `--pre 1` option. (When `--newest` or `--greatest` are set, `--pre 1` is set by default, and can be disabled with `--pre 0`). #### Options changed: `-m`, `--prod`, `--dev`, `--peer` In order to only target one or more dependency sections, ncu now uses the `--dep` option instead of separate options for each section. `--prod` is now `--dep prod` `--dev` is now `--dep dev` `--dev --peer` is now `--dep dev,peer` etc The `--packageManager` alias has changed from `-m` to `-p` to make room for `--minimal` as `-m`. ## [2.0.0] - 2005-08-14 v2 has a few important differences from v1: - Newer published versions that satisfy the specified range are _not_ upgraded by default (e.g. `1.0.0` to `1.1.0`). This change was made because `npm update` handles upgrades within the satisfied range just fine, and npm-check-updates is primarily intended to provide functionality not otherwise provided by npm itself. These satisfied dependencies will still be shown when you run npm-check-updates, albeit with a short explanation. **For the old behavior, add the -ua/--upgradeAll option.** - The command-line argument now specifies a package name filter (e.g. `ncu /^gulp-/`). For the old behavior (specifying an alternative package.json), pipe the package.json through stdin. - Use the easier-to-type `ncu` instead of `npm-check-updates`. `npm-check-updates` is preserved for backwards-compatibility. - Allow packageData to be specified as an option - Colored table output - Add -a/--upgradeAll - Add -e/--error-level option - Add -j/--json and --jsonFlat flags for json output - Add -r/--registry option for specifying third-party npm registry - Add -t/--greatest option to search for the highest versions instead of the default latest stable versions. - Remove -f/--filter option and move to command-line argument - Replace < and <= with ^ - Automatically look for the closest descendant package.json if not found in current directory - Add ncu alias - Export functionality to allow for programmatic use - Bug fixes and refactoring - Full unit test coverage! ================================================ FILE: Dockerfile ================================================ FROM node:latest RUN npm install -g npm-check-updates WORKDIR /app ENTRYPOINT ["npm-check-updates"] ================================================ FILE: LICENSE ================================================ Copyright 2025 Tomas Junnonen Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: README.md ================================================ # npm-check-updates [![npm version](https://img.shields.io/npm/v/npm-check-updates)](https://www.npmjs.com/package/npm-check-updates) [![Build Status](https://img.shields.io/github/actions/workflow/status/raineorshine/npm-check-updates/test.yml?branch=main&label=tests&logo=github)](https://github.com/raineorshine/npm-check-updates/actions?query=workflow%3ATests+branch%3Amain) **npm-check-updates upgrades your package.json dependencies to the _latest_ versions, ignoring specified versions.** - maintains existing semantic versioning _policies_, i.e. `"react": "^17.0.2"` to `"react": "^18.3.1"`. - _only_ modifies package.json file. Run `npm install` to update your installed packages and package-lock.json. - sensible defaults, but highly customizable - compatible with npm, yarn, pnpm, deno, and bun - CLI and module usage example output $${\color{red}Red}$$ major upgrade (and all [major version zero](https://semver.org/#spec-item-4))
$${\color{cyan}Cyan}$$ minor upgrade
$${\color{green}Green}$$ patch upgrade
## Installation Install globally to use `npm-check-updates` or the shorter `ncu`: ```sh npm install -g npm-check-updates ``` Or run with [npx](https://docs.npmjs.com/cli/v7/commands/npx) (only the long form is supported): ```sh npx npm-check-updates ``` ## Usage Check the latest versions of all project dependencies: ```sh $ ncu Checking package.json [====================] 5/5 100% eslint 7.32.0 → 8.0.0 prettier ^2.7.1 → ^3.0.0 svelte ^3.48.0 → ^3.51.0 typescript >3.0.0 → >4.0.0 untildify <4.0.0 → ^4.0.0 webpack 4.x → 5.x Run ncu -u to upgrade package.json ``` Upgrade a project's package file: > **Make sure your package file is in version control and all changes have been committed. This _will_ overwrite your package file.** ```sh $ ncu -u Upgrading package.json [====================] 1/1 100% express 4.12.x → 4.13.x Run npm install to install new versions. $ npm install # update installed packages and package-lock.json ``` Check global packages: ```sh ncu -g ``` ## Interactive Mode Choose which packages to update in interactive mode: ```sh ncu --interactive ncu -i ``` ![ncu --interactive](https://user-images.githubusercontent.com/750276/175337598-cdbb2c46-64f8-44f5-b54e-4ad74d7b52b4.png) Combine with `--format group` for a truly _luxe_ experience: ![ncu --interactive --format group](https://user-images.githubusercontent.com/750276/175336533-539261e4-5cf1-458f-9fbb-a7be2b477ebb.png) ### Keys - Select a package - Space Toggle selection - a Toggle all - Enter Upgrade ## Filter packages Filter packages using the `--filter` option or adding additional cli arguments: ```sh # upgrade only mocha ncu mocha ncu -f mocha ncu --filter mocha # upgrade only chalk, mocha, and react ncu chalk mocha react ncu chalk, mocha, react ncu -f "chalk mocha react" ``` Filter with wildcards or regex: ```sh # upgrade packages that start with "react-" ncu react-* ncu "/^react-.*$/" ``` Exclude specific packages with the `--reject` option or prefixing a filter with `!`. Supports strings, wildcards, globs, comma-or-space-delimited lists, and regex: ```sh # upgrade everything except nodemon ncu \!nodemon ncu -x nodemon ncu --reject nodemon # upgrade packages that do not start with "react-". ncu \!react-* ncu '/^(?!react-).*$/' # mac/linux ncu "/^(?!react-).*$/" # windows ``` Advanced filters: [filter](https://github.com/raineorshine/npm-check-updates#filter), [filterResults](https://github.com/raineorshine/npm-check-updates#filterresults), [filterVersion](https://github.com/raineorshine/npm-check-updates#filterversion) ## How dependency updates are determined - Direct dependencies are updated to the latest stable version: - `2.0.1` → `2.2.0` - `1.2` → `1.3` - `0.1.0` → `1.0.1` - Range operators are preserved and the version is updated: - `^1.2.0` → `^2.0.0` - `1.x` → `2.x` - `>0.2.0` → `>0.3.0` - "Less than" is replaced with a wildcard: - `<2.0.0` → `^3.0.0` - `1.0.0 < 2.0.0` → `^3.0.0` - "Any version" is preserved: - `*` → `*` - Prerelease versions are ignored by default. - Use `--pre` to include prerelease versions (e.g. `alpha`, `beta`, `build1235`) - Choose what level to upgrade to: - With `--target semver`, update according to your specified [semver](https://semver.org/) version ranges: - `^1.1.0` → `^1.9.99` - With `--target minor`, strictly update the patch and minor versions (including major version zero): - `0.1.0` → `0.2.1` - With `--target patch`, strictly update the patch version (including major version zero): - `0.1.0` → `0.1.2` - With `--target @next`, update to the version published on the `next` tag: - `0.1.0` -> `0.1.1-next.1` ## Options Options are merged with the following precedence: 1. Command line options 2. Local [Config File](#config-file) (current working directory) 3. Project Config File (next to package.json) 4. User Config File (`$HOME`) Options that take no arguments can be negated by prefixing them with `--no-`, e.g. `--no-peer`.
--cache Cache versions to a local cache file. Default --cacheFile is ~/.ncu-cache.json and default --cacheExpiration is 10 minutes.
--cacheClear Clear the default cache, or the cache file specified by --cacheFile.
--cacheExpiration <min> Cache expiration in minutes. Only works with --cache. (default: 10)
--cacheFile <path> Filepath for the cache file. Only works with --cache. (default: "~/.ncu-cache.json")
--color Force color in terminal.
--concurrency <n> Max number of concurrent HTTP requests to registry. (default: 8)
--configFileName <s> Config file name. (default: .ncurc.{json,yml,js,cjs})
--configFilePath <path> Directory of .ncurc config file. (default: directory of packageFile)
-c, --cooldown <period> Sets a minimum age for package versions to be considered for upgrade. Accepts a number (days) or a string with a unit: "7d" (days), "12h" (hours), "30m" (minutes). Reduces the risk of installing newly published, potentially compromised packages.
--cwd <path> Working directory in which npm will be executed.
--deep Run recursively in current working directory. Alias of (--packageFile '**/package.json').
--dep <value> Check one or more sections of dependencies only: dev, optional, peer, prod, or packageManager (comma-delimited). (default: ["prod","dev","optional","packageManager"])
--deprecated Include deprecated packages. Use --no-deprecated to exclude deprecated packages (20–25% slower). (default: true)
-d, --doctor Iteratively installs upgrades and runs tests to identify breaking upgrades. Requires -u to execute.
--doctorInstall <command> Specifies the install script to use in doctor mode. (default: npm install or the equivalent for your package manager)
--doctorTest <command> Specifies the test script to use in doctor mode. (default: npm test)
--enginesNode Include only packages that satisfy engines.node as specified in the package file.
-e, --errorLevel <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: 1)
-f, --filter <p> Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.
filterResults <fn> Filters results based on a user provided predicate function after fetching new versions.
--filterVersion <p> Filter on package version using comma-or-space-delimited list, /regex/, or predicate function.
--format <value> Modify the output formatting or show additional information. Specify one or more comma-delimited values: dep, group, ownerChanged, repo, time, lines, installedVersion. (default: [])
-g, --global Check global packages instead of in the current project.
groupFunction <fn> Customize how packages are divided into groups when using --format group.
--install <value> Control the auto-install behavior: always, never, prompt. (default: "prompt")
-i, --interactive Enable interactive prompts for each dependency; implies -u unless one of the json options are set.
-j, --jsonAll Output new package file instead of human-readable message.
--jsonDeps Like jsonAll but only lists dependencies, devDependencies, optionalDependencies, etc of the new package data.
--jsonUpgraded Output upgraded dependencies in json.
-l, --loglevel <n> Amount to log: silent, error, minimal, warn, info, verbose, silly. (default: "warn")
--mergeConfig Merges nested configs with the root config file for --deep or --packageFile options. (default: false)
-m, --minimal Do not upgrade newer versions that are already satisfied by the version range according to semver.
--packageData <value> Package file data (you can also use stdin).
--packageFile <path|glob> Package file(s) location. (default: ./package.json)
-p, --packageManager <s> npm, yarn, pnpm, deno, bun, staticRegistry (default: npm).
--peer Check peer dependencies of installed packages and filter updates to compatible versions.
--pre <n> Include prerelease versions, e.g. -alpha.0, -beta.5, -rc.2. Automatically set to 1 when --target is newest or greatest, or when the current version is a prerelease. (default: 0)
--prefix <path> Current working directory of npm.
-r, --registry <uri> Specify the registry to use when looking up package versions.
--registryType <type> Specify whether --registry refers to a full npm registry or a simple JSON file or url: npm, json. (default: npm)
-x, --reject <p> Exclude packages matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.
--rejectVersion <p> Exclude package.json versions using comma-or-space-delimited list, /regex/, or predicate function.
--removeRange Remove version ranges from the final package version.
--retry <n> Number of times to retry failed requests for package info. (default: 3)
--root Runs updates on the root project in addition to specified workspaces. Only allowed with --workspace or --workspaces. (default: true)
-s, --silent Don't output anything. Alias for --loglevel silent.
--stdin Read package.json from stdin.
-t, --target <value> Determines the version to upgrade to: latest, newest, greatest, minor, patch, semver, @[tag], or [function]. (default: latest)
--timeout <ms> Global timeout in milliseconds. (default: no global timeout and 30 seconds per npm-registry-fetch)
-u, --upgrade Overwrite package file with upgraded versions instead of just outputting to console.
--verbose Log additional information for debugging. Alias for --loglevel verbose.
--workspace <s> Run on one or more specified workspaces. Add --no-root to exclude the root project. (default: [])
-w, --workspaces Run on all workspaces. Add --no-root to exclude the root project.
## Advanced Options Some options have advanced usage, or allow per-package values by specifying a function in your .ncurc.js file. Run `ncu --help [OPTION]` to view advanced help for a specific option, or see below: ## cooldown Usage: ncu --cooldown [period] ncu -c [period] The cooldown option helps protect against supply chain attacks by requiring package versions to be published at least the given amount of time before considering them for upgrade. The value can be a plain number (days) or a string with a unit suffix: --cooldown 7 7 days --cooldown 7d 7 days (same as above) --cooldown 12h 12 hours --cooldown 30m 30 minutes Note that previous stable versions will not be suggested. The package will be completely ignored if its latest published version is within the cooldown period. This is due to a limitation of the npm registry, which does not provide a way to query previous stable versions. Example: Let's examine how cooldown works with a package that has these versions available: 1.0.0 Released 7 days ago (initial version) 1.1.0 Released 6 days ago (minor update) 1.1.1 Released 5 days ago (patch update) 1.2.0 Released 5 days ago (minor update) 2.0.0-beta.1 Released 5 days ago (beta release) 1.2.1 Released 4 days ago (patch update) 1.3.0 Released 4 days ago (minor update) [latest] 2.0.0-beta.2 Released 3 days ago (beta release) 2.0.0-beta.3 Released 2 days ago (beta release) [beta] With default target (latest): ```js $ ncu --cooldown 5 ``` No update will be suggested because: - Latest version (1.3.0) is only 4 days old. - Cooldown requires versions to be at least 5 days old - Use `--cooldown 4` or lower to allow this update With `@beta`/`@tag` target: ```js $ ncu --cooldown 3 --target @beta ``` No update will be suggested because: - Current beta (2.0.0-beta.3) is only 2 days old - Cooldown requires versions to be at least 3 days old - Use `--cooldown 2` or lower to allow this update With other targets: ```js $ ncu --cooldown 5 --target greatest|newest|minor|patch|semver ``` Each target will select the best version that is at least 5 days old: greatest → 1.2.0 (highest version number outside cooldown) newest → 2.0.0-beta.1 (most recently published version outside cooldown) minor → 1.2.0 (highest minor version outside cooldown) patch → 1.1.1 (highest patch version outside cooldown) Note for latest/tag targets: > :warning: For packages that update frequently (e.g. daily releases), using a long cooldown period (7+ days) with the default `--target latest` or `--target @tag` may prevent all updates since new versions will be published before older ones meet the cooldown requirement. Please consider this when setting your cooldown period. You can also provide a custom function in your .ncurc.js file or when importing npm-check-updates as a module. > :warning: The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions. ```js /** Set cooldown to 3 days but skip it for `@my-company` packages. @param packageName The name of the dependency. @returns Cooldown days restriction for given package. */ cooldown: packageName => (packageName.startsWith('@my-company') ? 0 : 3) ``` ## doctor Usage: ncu --doctor -u ncu --no-doctor ncu -du Iteratively installs upgrades and runs your project's tests to identify breaking upgrades. Reverts broken upgrades and updates package.json with working upgrades. Requires `-u` to execute (modifies your package file, lock file, and node_modules) To be more precise: 1. Runs `npm install` and `npm test` to ensure tests are currently passing. 2. Runs `ncu -u` to optimistically upgrade all dependencies. 3. If tests pass, hurray! 4. If tests fail, restores package file and lock file. 5. For each dependency, install upgrade and run tests. 6. Prints broken upgrades with test error. 7. Saves working upgrades to package.json. Additional options:
--doctorInstallspecify a custom install script (default: `npm install` or `yarn`)
--doctorTestspecify a custom test script (default: `npm test`)
Example: $ ncu --doctor -u Running tests before upgrading npm install npm run test Upgrading all dependencies and re-running tests ncu -u npm install npm run test Tests failed Identifying broken dependencies npm install npm install --no-save react@16.0.0 npm run test ✓ react 15.0.0 → 16.0.0 npm install --no-save react-redux@7.0.0 npm run test ✗ react-redux 6.0.0 → 7.0.0 /projects/myproject/test.js:13 throw new Error('Test failed!') ^ npm install --no-save react-dnd@11.1.3 npm run test ✓ react-dnd 10.0.0 → 11.1.3 Saving partially upgraded package.json ## filter Usage: ncu --filter [p] ncu -f [p] Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. Only included packages will be checked with `--peer`. `--filter` runs _before_ new versions are fetched, in contrast to `--filterResults` which runs _after_. You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates as a module. > :warning: The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions. ```js /** @param name The name of the dependency. @param semver A parsed Semver array of the current version. (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring) @returns True if the package should be included, false if it should be excluded. */ filter: (name, semver) => { if (name.startsWith('@myorg/')) { return false } return true } ``` ## filterResults Filters results based on a user provided predicate function after fetching new versions. `filterResults` runs _after_ new versions are fetched, in contrast to `filter`, `reject`, `filterVersion`, and `rejectVersion`, which run _before_. This allows you to exclude upgrades with `filterResults` based on how the version has changed (e.g. a major version change). > :warning: The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions. ```js /** Exclude major version updates. Note this could also be achieved with --target semver. @param {string} packageName The name of the dependency. @param {string} current Current version declaration (may be a range). @param {SemVer[]} currentVersionSemver Current version declaration in semantic versioning format (may be a range). @param {string} upgraded Upgraded version. @param {SemVer} upgradedVersionSemver Upgraded version in semantic versioning format. @returns {boolean} Return true if the upgrade should be kept; otherwise, it will be ignored. */ filterResults: (packageName, { current, currentVersionSemver, upgraded, upgradedVersionSemver }) => { const currentMajor = parseInt(currentVersionSemver[0]?.major, 10) const upgradedMajor = parseInt(upgradedVersionSemver?.major, 10) if (currentMajor && upgradedMajor) { return currentMajor >= upgradedMajor } return true } ``` For the SemVer type definition, see: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring ## filterVersion Usage: ncu --filterVersion [p] Include only versions matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. `--filterVersion` runs _before_ new versions are fetched, in contrast to `--filterResults` which runs _after_. You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates as a module. > :warning: The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions. This function is an alias for the `filter` option function. ```js /** @param name The name of the dependency. @param semver A parsed Semver array of the current version. (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring) @returns True if the package should be included, false if it should be excluded. */ filterVersion: (name, semver) => { if (name.startsWith('@myorg/') && parseInt(semver[0]?.major) > 5) { return false } return true } ``` ## format Usage: ncu --format [value] Modify the output formatting or show additional information. Specify one or more comma-delimited values.
depPrints the dependency type (dev, peer, optional) of each package.
groupGroups packages by major, minor, patch, and major version zero updates.
homepageDisplays links to the package's homepage if specified in its package.json.
installedVersionPrints the exact current version number instead of a range.
linesPrints name@version on separate lines. Useful for piping to npm install.
ownerChangedShows if the package owner has changed.
repoInfers and displays links to the package's source code repository. Requires packages to be installed.
diffDisplay link to compare the changes between package versions.
timeShows the publish time of each upgrade.
## groupFunction Customize how packages are divided into groups when using `--format group`. Only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions. ```js /** @param name The name of the dependency. @param defaultGroup The predefined group name which will be used by default. @param currentSpec The current version range in your package.json. @param upgradedSpec The upgraded version range that will be written to your package.json. @param upgradedVersion The upgraded version number returned by the registry. @returns A predefined group name ('major' | 'minor' | 'patch' | 'majorVersionZero' | 'none') or a custom string to create your own group. */ groupFunction: (name, defaultGroup, currentSpec, upgradedSpec, upgradedVersion) => { if (name === 'typescript' && defaultGroup === 'minor') { return 'major' } if (name.startsWith('@myorg/')) { return 'My Org' } return defaultGroup } ``` ## install Usage: ncu --install [value] Default: prompt Control the auto-install behavior.
alwaysRuns your package manager's install command automatically after upgrading.
neverDoes not install and does not prompt.
promptShows a message after upgrading that recommends an install, but does not install. In interactive mode, prompts for install. (default)
## packageManager Usage: ncu --packageManager [s] ncu -p [s] Specifies the package manager to use when looking up versions.
npmSystem-installed npm. Default.
yarnSystem-installed yarn. Automatically used if yarn.lock is present.
pnpmSystem-installed pnpm. Automatically used if pnpm-lock.yaml is present.
bunSystem-installed bun. Automatically used if bun.lock or bun.lockb is present.
## peer Usage: ncu --peer ncu --no-peer Check peer dependencies of installed packages and filter updates to compatible versions. Example: The following example demonstrates how `--peer` works, and how it uses peer dependencies from upgraded modules. The package ncu-test-peer-update has two versions published: - 1.0.0 has peer dependency `"ncu-test-return-version": "1.0.x"` - 1.1.0 has peer dependency `"ncu-test-return-version": "1.1.x"` Our test app has the following dependencies: "ncu-test-peer-update": "1.0.0", "ncu-test-return-version": "1.0.0" The latest versions of these packages are: "ncu-test-peer-update": "1.1.0", "ncu-test-return-version": "2.0.0" With `--peer`: ncu upgrades packages to the highest version that still adheres to the peer dependency constraints: ncu-test-peer-update 1.0.0 → 1.1.0 ncu-test-return-version 1.0.0 → 1.1.0 Without `--peer`: As a comparison: without using the `--peer` option, ncu will suggest the latest versions, ignoring peer dependencies: ncu-test-peer-update 1.0.0 → 1.1.0 ncu-test-return-version 1.0.0 → 2.0.0 ## registryType Usage: ncu --registryType [type] Specify whether `--registry` refers to a full npm registry or a simple JSON file.
npmDefault npm registry
jsonChecks versions from a file or url to a simple JSON registry. Must include the `--registry` option. Example: // local file $ ncu --registryType json --registry ./registry.json // url $ ncu --registryType json --registry https://api.mydomain/registry.json // you can omit --registryType when the registry ends in .json $ ncu --registry ./registry.json $ ncu --registry https://api.mydomain/registry.json registry.json: { "prettier": "2.7.1", "typescript": "4.7.4" }
## reject Usage: ncu --reject [p] ncu -x [p] The inverse of `--filter`. Exclude package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. This will also exclude them from the `--peer` check. `--reject` runs _before_ new versions are fetched, in contrast to `--filterResults` which runs _after_. You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates as a module. > :warning: The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions. ```js /** @param name The name of the dependency. @param semver A parsed Semver array of the current version. (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring) @returns True if the package should be excluded, false if it should be included. */ reject: (name, semver) => { if (name.startsWith('@myorg/')) { return true } return false } ``` ## rejectVersion Usage: ncu --rejectVersion [p] The inverse of `--filterVersion`. Exclude versions matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. `--rejectVersion` runs _before_ new versions are fetched, in contrast to `--filterResults` which runs _after_. You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates as a module. > :warning: The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions. This function is an alias for the reject option function. ```js /** @param name The name of the dependency. @param semver A parsed Semver array of the current version. (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring) @returns True if the package should be excluded, false if it should be included. */ rejectVersion: (name, semver) => { if (name.startsWith('@myorg/') && parseInt(semver[0]?.major) > 5) { return true } return false } ``` ## target Usage: ncu --target [value] ncu -t [value] Determines the version to upgrade to. (default: "latest")
greatestUpgrade to the highest version number published, regardless of release date or tag. Includes prereleases.
latestUpgrade to whatever the package's "latest" git tag points to. Excludes prereleases unless --pre is specified.
minorUpgrade to the highest minor version without bumping the major version.
newestUpgrade to the version with the most recent publish date, even if there are other version numbers that are higher. Includes prereleases.
patchUpgrade to the highest patch version without bumping the minor or major versions.
semverUpgrade to the highest version within the semver range specified in your package.json.
@[tag]Upgrade to the version published to a specific tag, e.g. 'next' or 'beta'.
e.g. ncu --target semver You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates as a module. > :warning: The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions. ```js /** Upgrade major version zero to the next minor version, and everything else to latest. @param name The name of the dependency. @param semver A parsed Semver object of the upgraded version. (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring) @returns One of the valid target values (specified in the table above). */ target: (name, semver) => { if (parseInt(semver[0]?.major) === '0') return 'minor' return 'latest' } ``` ## Config File Add a `.ncurc.{json,yml,js,cjs}` file to your project directory to specify configuration information. For example, `.ncurc.json`: ```json { "upgrade": true, "filter": "svelte", "reject": ["@types/estree", "ts-node"] } ``` Options are merged with the following precedence: 1. Command line options 2. Local Config File (current working directory) 3. Project Config File (next to package.json) 4. User Config File (`$HOME`) You can also specify a custom config file name or path using the `--configFileName` or `--configFilePath` command line options. ### Config Functions Some options offer more advanced configuration using a function definition. These include [filter](https://github.com/raineorshine/npm-check-updates#filter), [filterVersion](https://github.com/raineorshine/npm-check-updates#filterversion), [filterResults](https://github.com/raineorshine/npm-check-updates#filterresults), [reject](https://github.com/raineorshine/npm-check-updates#reject), [rejectVersion](https://github.com/raineorshine/npm-check-updates#rejectversion), and [groupFunction](https://github.com/raineorshine/npm-check-updates#groupfunction). To define an options function, convert the config file to a JS file by adding the `.js` extension and setting module.exports: For example, `.ncurc.js`: ```js /** @type {import('npm-check-updates').RcOptions } */ module.exports = { upgrade: true, filter: name => name.startsWith('@myorg/'), } ``` Alternatively, you can use the defineConfig helper which should provide intellisense without the need for jsdoc annotations: ```js const { defineConfig } = require('npm-check-updates') module.exports = defineConfig({ upgrade: true, filter: name => name.startsWith('@myorg/'), }) ``` ### JSON Schema If you write `.ncurc` config files using json or yaml, you can add the JSON Schema to your IDE settings for completions. e.g. for VS Code: ```json "json.schemas": [ { "fileMatch": [ ".ncurc", ".ncurc.json", ], "url": "https://raw.githubusercontent.com/raineorshine/npm-check-updates/main/src/types/RunOptions.json" } ], "yaml.schemas": { "https://raw.githubusercontent.com/raineorshine/npm-check-updates/main/src/types/RunOptions.json": [ ".ncurc.yml", ] }, ``` ## Module/Programmatic Usage npm-check-updates can be imported as a module: ```js import ncu from 'npm-check-updates' const upgraded = await ncu.run({ // Pass any cli option packageFile: '../package.json', upgrade: true, // Defaults: // jsonUpgraded: true, // silent: true, }) console.log(upgraded) // { "mypackage": "^2.0.0", ... } ``` ## Contributing Contributions are happily accepted. I respond to all PR's and can offer guidance on where to make changes. For contributing tips see [CONTRIBUTING.md](https://github.com/raineorshine/npm-check-updates/blob/main/.github/CONTRIBUTING.md). ## Problems? [File an issue](https://github.com/raineorshine/npm-check-updates/issues). Please [search existing issues](https://github.com/raineorshine/npm-check-updates/issues?utf8=%E2%9C%93&q=is%3Aissue) first. ================================================ FILE: deploy.md ================================================ # Deployment Instructions - Have you created tests? - Have you updated the README? ```bash npm version [minor] git push && git push --tags npm publish [--tag unstable] ``` - Update the release history ================================================ FILE: package.json ================================================ { "name": "npm-check-updates", "version": "19.6.5", "author": "Tomas Junnonen ", "license": "Apache-2.0", "contributors": [ "Raine Revere (https://github.com/raineorshine)", "Imamuzzaki Abu Salam " ], "description": "Find newer versions of dependencies than what your package.json allows", "keywords": [ "dependencies", "npm", "package.json", "update", "upgrade", "versions" ], "engines": { "node": ">=20.0.0", "npm": ">=8.12.1" }, "main": "build/index.js", "types": "build/index.d.ts", "scripts": { "build": "rimraf build && npm run build:options && vite build", "build:options": "vite-node src/scripts/build-options.ts", "build:analyze": "rimraf build && npm run build:options && ANALYZER=true vite build", "lint": "cross-env FORCE_COLOR=1 npm-run-all --parallel --aggregate-output lint:*", "lint:lockfile": "lockfile-lint", "lint:markdown": "markdownlint \"**/*.md\" --ignore \"**/node_modules/**/*.md\" --ignore build --config .markdownlint.js", "lint:src": "eslint --cache --cache-location node_modules/.cache/.eslintcache --ignore-path .gitignore --report-unused-disable-directives .", "prepare": "src/scripts/install-hooks", "prepublishOnly": "npm run build", "prettier": "prettier . --check", "prettier:fix": "prettier . --write", "test": "npm run test:unit && npm run test:e2e", "test:bun": "test/bun-install.sh && mocha test/bun", "test:unit": "mocha test test/package-managers/*", "test:e2e": "./test/e2e.sh", "ncu": "node build/cli.js" }, "bin": { "npm-check-updates": "build/cli.js", "ncu": "build/cli.js" }, "repository": { "type": "git", "url": "git+https://github.com/raineorshine/npm-check-updates.git" }, "homepage": "https://github.com/raineorshine/npm-check-updates", "bugs": { "url": "https://github.com/raineorshine/npm-check-updates/issues" }, "overrides": { "ip": "2.0.1", "jsonparse": "https://github.com/ARitz-Cracker/jsonparse/tree/patch-1", "@yarnpkg/parsers": "2.6.0" }, "devDependencies": { "@trivago/prettier-plugin-sort-imports": "^5.2.2", "@types/bun": "^1.2.23", "@types/chai": "^4.3.19", "@types/chai-as-promised": "^8.0.0", "@types/chai-string": "^1.4.5", "@types/cli-table": "^0.3.4", "@types/hosted-git-info": "^3.0.5", "@types/ini": "^4.1.1", "@types/js-yaml": "^4.0.9", "@types/jsonlines": "^0.1.5", "@types/lodash": "^4.17.20", "@types/mocha": "^10.0.10", "@types/node": "^24.5.2", "@types/npm-registry-fetch": "^8.0.8", "@types/parse-github-url": "^1.0.3", "@types/picomatch": "^4.0.2", "@types/progress": "^2.0.7", "@types/prompts": "^2.4.9", "@types/semver": "^7.7.1", "@types/semver-utils": "^1.1.3", "@types/sinon": "^17.0.4", "@types/update-notifier": "^6.0.8", "@typescript-eslint/eslint-plugin": "^8.44.1", "@typescript-eslint/parser": "^8.44.1", "camelcase": "^6.3.0", "chai": "^4.3.10", "chai-as-promised": "^7.1.2", "chai-string": "^1.6.0", "chalk": "^5.6.2", "cli-table3": "^0.6.5", "commander": "^14.0.1", "cross-env": "^10.0.0", "dequal": "^2.0.3", "eslint": "^8.57.0", "eslint-config-prettier": "^10.1.8", "eslint-config-raine": "^0.5.0", "eslint-config-standard": "^17.1.0", "eslint-plugin-import": "^2.32.0", "eslint-plugin-jsdoc": "^60.5.0", "eslint-plugin-n": "^16.6.2", "eslint-plugin-promise": "^6.6.0", "fast-glob": "^3.3.3", "fast-memoize": "^2.5.2", "find-up": "5.0.0", "fp-and-or": "^1.0.2", "hosted-git-info": "^9.0.0", "ini": "^5.0.0", "js-yaml": "^4.1.0", "jsonc-parser": "^3.3.1", "jsonlines": "^0.1.1", "lockfile-lint": "^4.14.1", "lodash": "^4.17.21", "markdownlint-cli": "^0.45.0", "mocha": "^11.7.2", "npm-registry-fetch": "^19.0.0", "npm-run-all": "^4.1.5", "p-map": "^4.0.0", "parse-github-url": "^1.0.3", "picomatch": "^4.0.3", "prettier": "^3.6.2", "progress": "^2.0.3", "prompts-ncu": "^3.0.2", "rc-config-loader": "^4.1.3", "rfdc": "^1.4.1", "rimraf": "^6.0.1", "rollup-plugin-node-externals": "^8.1.1", "semver": "^7.7.2", "semver-utils": "^1.1.4", "should": "^13.2.3", "sinon": "^21.0.0", "source-map-support": "^0.5.21", "spawn-please": "^3.0.0", "strip-ansi": "^7.1.2", "ts-node": "^10.9.2", "typescript": "^5.9.2", "typescript-json-schema": "^0.65.1", "untildify": "^4.0.0", "update-notifier": "^7.3.1", "verdaccio": "^6.1.6", "vite": "^7.1.7", "vite-bundle-analyzer": "^1.2.3", "vite-node": "^3.2.4", "vite-plugin-dts": "^4.5.4", "yaml": "^2.8.2", "yarn": "^1.22.22", "zod": "^4.3.5" }, "files": [ "build", "!**/test/**" ], "lockfile-lint": { "allowed-schemes": [ "https:", "git+ssh:" ], "allowed-hosts": [ "npm", "github.com" ], "empty-hostname": false, "type": "npm ", "path": "package-lock.json" }, "mocha": { "check-leaks": true, "extension": [ "test.ts" ], "require": [ "source-map-support/register", "ts-node/register" ], "timeout": 60000, "trace-deprecation": true, "trace-warnings": true, "use_strict": true } } ================================================ FILE: src/bin/cli.ts ================================================ #!/usr/bin/env node import { Help, Option, program } from 'commander' import createCloneDeep from 'rfdc' import semver from 'semver' import pkg from '../../package.json' import cliOptions, { renderExtendedHelp } from '../cli-options' import ncu from '../index' import { chalkInit } from '../lib/chalk' // async global contexts are only available in esm modules -> function import getNcuRc from '../lib/getNcuRc' import { pickBy } from '../lib/pick' const optionVersionDescription = 'Output the version number of npm-check-updates.' /** Removes inline code ticks. */ const uncode = (s: string) => s.replace(/`/g, '') const cloneDeep = createCloneDeep() ;(async () => { // importing update-notifier dynamically as esm modules are only allowed to be dynamically imported inside of cjs modules const { default: updateNotifier } = await import('update-notifier') // check if a new version of ncu is available and print an update notification // // For testing from specific versions, use: // // updateNotifier({ // pkg: { // name: 'npm-check-updates', // version: x.y.z // }, // updateCheckInterval: 0 // }) const notifier = updateNotifier({ pkg }) if (notifier.update && notifier.update.latest !== pkg.version) { const { default: chalk } = await import('chalk') // generate release urls for all the major versions from the current version up to the latest const currentMajor = semver.parse(notifier.update.current)?.major const latestMajor = semver.parse(notifier.update.latest)?.major const majorVersions = // Greater than or equal to (>=) will always return false if either operant is NaN or undefined. // Without this condition, it can result in a RangeError: Invalid array length. // See: https://github.com/raineorshine/npm-check-updates/issues/1200 currentMajor && latestMajor && latestMajor >= currentMajor ? new Array(latestMajor - currentMajor).fill(0).map((x, i) => currentMajor + i + 1) : [] const releaseUrls = majorVersions.map(majorVersion => `${pkg.homepage ?? ''}/releases/tag/v${majorVersion}.0.0`) // for non-major updates, generate a URL to view all commits since the current version const compareUrl = `${pkg.homepage ?? ''}/compare/v${notifier.update.current}...v${notifier.update.latest}` notifier.notify({ defer: false, isGlobal: true, message: `Update available ${chalk.dim('{currentVersion}')}${chalk.reset(' → ')}${ notifier.update.type === 'major' ? chalk.red('{latestVersion}') : notifier.update.type === 'minor' ? chalk.yellow('{latestVersion}') : chalk.green('{latestVersion}') } Run ${chalk.cyan('{updateCommand}')} to update ${chalk.dim.underline( notifier.update.type === 'major' ? releaseUrls.map(url => chalk.dim.underline(url)).join('\n') : compareUrl, )}`, }) } // manually detect option-specific help // https://github.com/raineorshine/npm-check-updates/issues/787 const rawArgs = process.argv.slice(2) const indexHelp = rawArgs.findIndex(arg => arg === '--help' || arg === '-h') if (indexHelp !== -1 && rawArgs[indexHelp + 1]) { const helpOption = rawArgs[indexHelp + 1].replace(/^-*/, '') if (helpOption === 'help' || helpOption === 'h') { console.info('Would you like some help with your help?') } else { await chalkInit() const nonHelpArgs = [...rawArgs.slice(0, indexHelp), ...rawArgs.slice(indexHelp + 1)] nonHelpArgs.forEach(arg => { // match option by long or short const query = arg.replace(/^-*/, '') const option = cliOptions.find( option => query === option.long || query === option.short || (query === `no-${option.long}` && option.type === 'boolean'), ) if (option) { console.info(renderExtendedHelp(option) + '\n') } else if (query === 'version' || query === 'v' || query === 'V') { console.info( renderExtendedHelp({ long: 'version', short: 'v', description: optionVersionDescription, // do not pass boolean or it will print --no-version type: 'string', }) + '\n', ) } else { console.info(`Unknown option: ${arg}`) } }) } process.exit(0) } // a set of options that only work in an rc config file, not on the command line const noCli = new Set(cliOptions.filter(option => option.cli === false).map(option => `--${option.long}`)) // start commander program program .description('[filter] is a list or regex of package names to check (all others will be ignored).') .usage('[options] [filter]') // See: boolean optional arg below .configureHelp({ optionTerm: option => option.long && noCli.has(option.long) ? option.long.replace('--', '') + '*' : option.long === '--version' ? // add -v to version help to cover the alias added below '-v, -V, --version' : option.flags.replace('[bool]', ''), optionDescription: option => option.long === '--version' ? optionVersionDescription : option.long === '--help' ? `You're lookin' at it. Run "ncu --help