- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3.8k
install: Don't omit any deps of dev deps if --only=dev #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    At the moment, npm will NOT install a dependency that is both a
production and a development dependency in the same tree if
`--only=dev`.
Consider the following scenario:
- `package1` has `prod-dependency` in `dependencies`
- `package1` has `dev-dependency` in `devDependencies`
- `prod-dependency` has `sub-dependency` in `dependencies`
- `dev-dependency` has `sub-dependency` in `dependencies`
So both `prod-dependency` and `dev-dependency` directly depend on
`sub-dependency`. Since `sub-dependency` is required by at least one
production dependency, then npm won't consider it as "only a dev
dependency", and therefore running `npm install --only=dev` will result
in the following tree:
```
package1/
    node_modules/
        dev-dependency
```
Notice that `sub-dependency` has ben completely omitted from the tree,
even though `dev-dependency` clearly requires it, and therefore it will
not work.
This commit makes `--only=dev` always install required dependencies of
dev dependencies, so you never end up with a broken tree.
For a more real-world reproducible example, try to run `npm install
--only=dev` in
https://github.com/resin-io/etcher/tree/a338c6e60a10aad00008febfe92e2556dcf586c6.
The resulting tree will be completely broken, but we would not have
identified this if several install scripts wouldn't fail as a result.
Signed-off-by: Juan Cruz Viotti <[email protected]>
    | I'd like a review from @iarna on this one. | 
| Re-ping @iarna :) | 
    
  zkat 
      pushed a commit
      that referenced
      this pull request
    
      Mar 5, 2019 
    
    
      
  
    
      
    
  
* install: Don't omit any deps of dev deps if --only=dev
At the moment, npm will NOT install a dependency that is both a
production and a development dependency in the same tree if
`--only=dev`.
Consider the following scenario:
- `package1` has `prod-dependency` in `dependencies`
- `package1` has `dev-dependency` in `devDependencies`
- `prod-dependency` has `sub-dependency` in `dependencies`
- `dev-dependency` has `sub-dependency` in `dependencies`
So both `prod-dependency` and `dev-dependency` directly depend on
`sub-dependency`. Since `sub-dependency` is required by at least one
production dependency, then npm won't consider it as "only a dev
dependency", and therefore running `npm install --only=dev` will result
in the following tree:
```
package1/
    node_modules/
        dev-dependency
```
Notice that `sub-dependency` has ben completely omitted from the tree,
even though `dev-dependency` clearly requires it, and therefore it will
not work.
This commit makes `--only=dev` always install required dependencies of
dev dependencies, so you never end up with a broken tree.
For a more real-world reproducible example, try to run `npm install
--only=dev` in
https://github.com/resin-io/etcher/tree/a338c6e60a10aad00008febfe92e2556dcf586c6.
The resulting tree will be completely broken, but we would not have
identified this if several install scripts wouldn't fail as a result.
PR-URL: #69
Credit: @jviotti
Reviewed-By: @iarna
    
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
At the moment, npm will NOT install a dependency that is both a
production and a development dependency in the same tree if
--only=dev.Consider the following scenario:
package1hasprod-dependencyindependenciespackage1hasdev-dependencyindevDependenciesprod-dependencyhassub-dependencyindependenciesdev-dependencyhassub-dependencyindependenciesSo both
prod-dependencyanddev-dependencydirectly depend onsub-dependency. Sincesub-dependencyis required by at least oneproduction dependency, then npm won't consider it as "only a dev
dependency", and therefore running
npm install --only=devwill resultin the following tree:
Notice that
sub-dependencyhas ben completely omitted from the tree,even though
dev-dependencyclearly requires it, and therefore it willnot work.
This commit makes
--only=devalways install required dependencies ofdev dependencies, so you never end up with a broken tree.
For a more real-world reproducible example, try to run
npm install --only=devinhttps://github.com/resin-io/etcher/tree/a338c6e60a10aad00008febfe92e2556dcf586c6.
The resulting tree will be completely broken, but we would not have
identified this if several install scripts wouldn't fail as a result.
Signed-off-by: Juan Cruz Viotti [email protected]