GithubHelp home page GithubHelp logo

mathieumg / npm-check-updates Goto Github PK

View Code? Open in Web Editor NEW

This project forked from raineorshine/npm-check-updates

0.0 2.0 0.0 417 KB

Find newer versions of Node.js dependencies than what your package.json allows

License: Other

JavaScript 100.00%

npm-check-updates's Introduction

NPM version Build Status Dependency Status

npm-check-updates is a command-line tool that allows you to upgrade your package.json or bower.json dependencies to the latest versions, regardless of existing version constraints.

npm-check-updates maintains your existing semantic versioning policies, i.e., it will upgrade your "express": "^4.11.2" dependency to "express": "^5.0.0" when express 5.0.0 is released.

npm-check-updates-screenshot

Question Having issues? Check out known issues first. Then check the issues page.

Installation

npm install -g npm-check-updates

Usage

Show any new dependencies for the project in the current directory:

$ ncu

 express           4.12.x  →   4.13.x
 multer            ^0.1.8  →   ^1.0.1
 react-bootstrap  ^0.22.6  →  ^0.24.0
 react-a11y        ^0.1.1  →   ^0.2.6
 webpack          ~1.9.10  →  ~1.10.5

Run with -u to upgrade your 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.

$ ncu -u

 express           4.12.x  →   4.13.x

package.json upgraded

Works with bower:

$ ncu -m bower     # will use bower.json and check versions in bower

You can include or exclude specific packages using the --filter and --reject options. They accept strings, comma-delimited lists, or regular expressions:

# match mocha and should packages exactly
$ ncu mocha             # shorthand for ncu -f mocha (or --filter)
$ ncu one, two, three

# exclude packages
$ ncu -x nodemon        # shorthand for ncu --reject nodemon

# match packages that start with "gulp-" using regex
$ ncu /^gulp-/

# match packages that do not start with "gulp-". Note: single quotes are required
# here to avoid inadvertent bash parsing
$ ncu '/^(?!gulp-).*$/'

Options

-d, --dev                check only devDependencies
-e, --error-level        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)
-f, --filter             include only package names matching the given string, 
                         comma-delimited list, or regex
-g, --global             check global packages instead of in the current project
-h, --help               output usage information
-j, --jsonAll            output new package file instead of human-readable
                         message
--jsonUpgraded           output upgraded dependencies in json
-l, --loglevel           what level of logs to report: silent, error, warn, info, 
                         verbose, silly (default: warn)
--packageData            include stringified package file (use stdin instead)
--packageFile            package file location (default: ./package.json)
--packageFileDir         use same directory as packageFile to compare against 
                         installed modules. See #201.
-m, --packageManager     npm or bower (default: npm)
-n, --newest             find the newest versions available instead of the
                         latest stable versions (alpha release only)
-o, --optional           check only optionalDependencies
-p, --prod               check only dependencies (not devDependencies)
-r, --registry           specify third-party NPM registry
-s, --silent             don't output anything (--loglevel silent)
-t, --greatest           find the highest versions available instead of the
                         latest stable versions (alpha release only)
-u, --upgrade            overwrite package file
-a, --upgradeAll         include even those dependencies whose latest
                         version satisfies the declared semver dependency
-x, --reject             exclude packages matching the given string, comma-
                         delimited list, or regex
-V, --version            output the version number
--semverLevel            find the highest version within "major" or "minor"

Integration

The tool allows integration with 3rd party code:

const ncu = require('npm-check-updates');

ncu.run({
    // Always specify the path to the package file
    packageFile: 'package.json',
    // Any command-line option can be specified here.
    // These are set by default:
    silent: true,
    jsonUpgraded: true
}).then((upgraded) => {
    console.log('dependencies to upgrade:', upgraded);
});

How dependency updates are determined

  • Direct dependencies will be increased to the latest stable version:
    • 2.0.12.2.0
    • 1.21.3
    • 0.1.01.0.1
    • with --semverLevel major
      • 0.1.00.2.1
    • with --semverLevel minor
      • 0.1.00.1.2
  • Semantic versioning policies for levels are maintained while satisfying the latest version:
  • ^1.2.0^2.0.0
  • 1.x2.x
  • "Any version" is maintained:
    • **
  • "Greater than" is maintained:
    • >0.2.0>0.3.0
  • Closed ranges are replaced with a wildcard:
    • 1.0.0 < 2.0.0^3.0.0

Why is it not updating ^1.0.0 to ^1.0.1 when 1.0.1 is the latest?

^1.0.0 is a range that will includes all non-major updates. If you run npm update, it will install 1.0.1 without changing the dependency listed in your package file. You don't need to update your package file if the latest version is satisfied by the specified dependency range. If you really want to upgrade your package file (even though it's not necessary), you can run ncu --upgradeAll.

Docker

Docker volumes can be used to easily update a package:

docker run -it --rm -v $(pwd)/package.json:/app/package.json creack/ncu -u -a

Known Issues

  • ncu -g incorrectly report that all packages are up-to-date. This is due to an issue in npm v3 in which dead symlinks break npm ls -g. See #235 for a workaround (TLDR; Delete the dead symlinks). For others, it was an issue with the npm prefix path. Try PREFIX="/usr/local/" ncu -g (#146).

  • In some environments (Windows?) npm-check-updates may hang. Run ncu --loglevel verbose to see if it is waiting for stdin. If so, try setting the package file explicitly: ncu -g --packageFile package.json. See #136.

  • There is an issue with grunt-shell described in #119. TLDR; You have to explicitly specify your package file with ncu --packageFile package.json.

  • Cannot find module 'proto-list'. This error is occurring for many people, yet it cannot be consistently reproduced. It seems to be fixed by fresh installs of node and npm: "I reinstalled node 4.2.1 and npm 2.14.7. Installed ncu, and it worked fine. So I'm afraid I'm not able to reproduce the issue anymore." See #144.

Problems?

Please file an issue on github! Contributors are responsive and happy to assist.

When filing an issue, please include the dependencies from your package file (or the output from npm -g ls --depth=0 if using global mode).

Contributing

npm-check-updates is a great project to contribute to! This is a newbie-friendly project, so don't hesitate to dive in and ask questions! Pick an issue that that you would like to work on and then look at the source code to see if you can figure out what to change. There are several outstanding bugs. There are also many enhancements labeled as revive-me that can be re-opened if someone is interested in working on them.

npm-check-updates's People

Contributors

raineorshine avatar tjunnone avatar etiktin avatar amilajack avatar nitriques avatar dimafeng avatar peterdavehello avatar yamalight avatar sanemat avatar undozen avatar billyjanitsch avatar binduwavell avatar gerhobbelt avatar creack avatar listepo avatar jwarkentin avatar lauritzsh avatar waffle-iron avatar mklement0 avatar nielsgl avatar panuhorsmalahti avatar nightwolfz avatar siilwyn avatar mourner avatar xhmikosr avatar z11h avatar justinhelmer avatar

Watchers

James Cloos avatar Mathieu M-Gosselin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.