Skip to content

Instantly share code, notes, and snippets.

@DanielHeath
Created December 13, 2016 05:01
Show Gist options
  • Select an option

  • Save DanielHeath/bb56e1cdd59d29eba6433b78d492c855 to your computer and use it in GitHub Desktop.

Select an option

Save DanielHeath/bb56e1cdd59d29eba6433b78d492c855 to your computer and use it in GitHub Desktop.

Revisions

  1. DanielHeath created this gist Dec 13, 2016.
    11 changes: 11 additions & 0 deletions NPM and shrinkwrapping.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # How does npm >4.0 work with shrinkwrapping?

    ## What happens when I run `npm i` without a shrinkwrap file
    For each dependency specified in package.json, npm attempts to find a compatible version, and installs it (and all dependencies, transitively) to node_modules

    ## What happens when I run `npm i` with a shrinkwrap file
    The exact versions of the libraries specified in the shrinkwrap file are installed, regardless of whether they match package.json or have their dependencies met.

    ## What happens when I run `npm shrinkwrap`?
    The exact versions of the currently installed libraries in `node_modules` are written to `npm-shrinkwrap.json`.
    The reason they are there (eg is this a devDependency) are also recorded, so you can later `npm i --production` to skip the devDependencies.