https://github.com/dmnd/use-sw-bug
Uses codykrainock/sw-bug to illustrate the bug with shrinkwrap.
https://github.com/dmnd/use-sw-bug
Last synced: about 2 months ago
JSON representation
Uses codykrainock/sw-bug to illustrate the bug with shrinkwrap.
- Host: GitHub
- URL: https://github.com/dmnd/use-sw-bug
- Owner: dmnd
- Created: 2016-07-08T03:54:38.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-08T03:57:31.000Z (about 10 years ago)
- Last Synced: 2025-11-15T04:22:15.042Z (8 months ago)
- Language: Shell
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# npm-shrinkwrap dependency mismatch bug
## Overview
In certain scenarios, `npm shrinkwrap` does not fix mismatches between dependencies installed in `node_modules` and dependencies listed in `npm-shrinkwrap.json`. One such scenario is described below, where a dependency from a specific repository is used.
For this proof of concept, the repository `codykrainock/sw-bug` is used as the dependency. This repository only has two "versions" - each represented by a separate commit.
## Steps to reproduce
`./bug-reproduce.sh` can be run to reproduce the issue. The steps to reproduce are also outlined here.
### 0. Clone this repository
```
git clone https://github.com/codykrainock/use-sw-bug.git
cd use-sw-bug
```
### 1. Clean the local environment
This will not be necessary if the repo is freshly cloned.
```
rm -rf node_modules/
```
### 2. Install dependencies listed in `package.json` and `npm-shrinkwrap.json`
The example here uses `codykrainock/sw-bug`, a repository with two versions represented by two commits. `package.json` and `npm-shrinkwrap.json` point to the first version.
```
npm install
```
### 3. Update a dependency that points to a specific repository
This uses the `sw-bug` repository described in the last step. Here, newest version of the repository (represented by the second commit) is installed to `node_modules`.
```
npm install sw-bug --save
```
### 4. Undo any changes to `npm-shrinkwrap.json`
After this step, the dependency represented by `npm-shrinkwrap.json` is the first version of `sw-bug`, whereas
```
git checkout -- npm-shrinkwrap.json
```
### 5. Install dependencies listed in `package.json` and `npm-shrinkwrap.json`
```
npm install
```
This is the same as step 2, and in theory, our local environment should match what is represented by `package.json`/`npm-shrinkwrap.json`. However, after this step, version 2 of `sw-bug` is in `node_modules/` whereas version 1 is in `npm-shrinkwrap.json`.
## Versions
```
$ npm -v
3.8.3
$ node -v
v5.10.0
```