Skip to content
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

Yarn doesn't install non-optional sub-dependencies when --ignore-optional is used and one or more other packages mark it as optional #1233

Closed
mnpenner opened this issue Oct 19, 2016 · 2 comments

Comments

@mnpenner
Copy link

Do you want to request a feature or report a bug?

Bug

If the current behavior is a bug, please provide the steps to reproduce.

Sorry, I tried to create an SSCCE but couldn't recreate this issue outside of my project.

First, here's my attempt. Create this package.json:

{
  "name": "yarntest",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "webpack": "^1.13.2"
  },
  "scripts": {
    "build": "webpack --progress"
  }
}

Run yarn.

It installs a ton of dependencies including one called graceful-fs. If you run yarn why graceful-fs it tells us:

This module exists because "webpack#enhanced-resolve" depends on it.

Which is great.

However, in my other project which also depends on webpack, graceful-fs is not installed!

However, when I run yarn why graceful-fs it tells me:

This module exists because "less" depends on it.

So... does that mean it thinks it installed graceful-fs? Because the directory node_modules/graceful-fs simply isn't there.

You will probably want to see the package.json for that project, so here it is.

I did manage to reproduce this error by copying those dependencies (and devDependencies) into my test project. I tried deleting node_modules and yarn.lock. Happens every time. graceful-fs is missing.

It might be some strange conflict between the less and webpack packages.

What is the current behavior?

Missing package(s).

What is the expected behavior?

All sub-dependencies are installed.

Please mention your node.js, yarn and operating system version.

Node: v6.3.1
Yarn: 0.16.0
OS: Win10 Anniversary

@mnpenner
Copy link
Author

mnpenner commented Oct 19, 2016

I verified that the issue is reproducible with just those two packages:

{
  "name": "yarntest",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {
    "less": "^2.7.1",
    "webpack": "^1.12.14"
  },
  "scripts": {
    "build": "webpack --progress"
  }
}

Oh... and I think I know that the problem is.

less lists graceful-fs as an "optional" dependency but I've been using --ignore-optional due to bug #1217.

The problem is that graceful-fs is not optional for webpack, so it should have got installed anyway (and it does if I omit less).

@mnpenner mnpenner changed the title Yarn doesn't install all sub-dependencies Yarn doesn't install non-optional sub-dependencies when --ignore-optional is used and one or more other packages mark it as optional Oct 19, 2016
@bestander
Copy link
Member

Merging into #2666

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants