yarn
yarn copied to clipboard
yarn --ignore-optional does not work properly
Do you want to request a feature or report a bug? bug.
What is the current behavior?
if i run yarn --ignore-optional somepackage
I will get an error and unable to install somepackage
if it depends on a private dependency that has been marked as optional.
If the current behavior is a bug, please provide the steps to reproduce.
yarn add --ignore-optional wix-storybook-utils
What is the expected behavior?
installs the package. Saves the pref so other people can install it too by running yarn install
.
Please mention your node.js, yarn and operating system version. OS X, yarn 1.6.0, node v9.11.1
Yarn still has to be able to pull the metadata for the package to determine where it would be installed in node_modules if it were there and put it in the lockfile and get hoisting correct. This is basically the same as yarn install --prod
still querying devDependencies
. This is pretty much as-designed in yarn's scheme of making builds deterministic.
npm will completely ignore them, but also means npm is not deterministic (the result of an install may have different versions or hoist locations if the optional package was or wasn't available), so if this is a deal-breaker for you, you might actually want to use npm instead.
For reference, #3630
That issue was left open, so maybe we should with this one too. Although "fixing" it would, I think, fundamentally break deterministic builds and it unlikely to actually change.
@rally25rs i hear you on it breaking deterministic builds, thats why i think the pref should be saved per package (somehow, maybe in lock file). That way if optionals are ignored, they are ignored forever, and if the pref changes it would require dependencies to be resolved again. I think this would still preserve the goals of yarn and still allow me to install the package i want to install :)
@rally25rs so the point i'm making is that no-optional
wouldn't just not install it, but completely exclude it from the build.
Hi
Adding to the thread.
I'm behind a corporate firewall, experiencing a somewhat similar problem when trying to add a global package.
Executing:
yarn global add pm2 || yarn global add --ignore-optional pm2
Results in:
error An unexpected error occurred: "https://tgz.pm2.io/gkt-1.0.0.tgz: Request failed \"403 Forbidden\"".
Environment: OSX, Yarn 1.7.0, Node v8.11.2 (LTS)
Workaround:
npm install -g pm2
Yeah, I still don't think the statement "fundamentally breaks deterministic builds" makes sense. This is an optional package, all of the software can function without this package in perpetuity. If you want to permanently exclude this optional package, there is no reason to resolve it.
Even if yarn tries to load metadata - in the end it shouldn't bail out with an error if it fails to do so for optional dependencies.
It would be nice to find away to make this work. I have a number of private packages that are used in a mono-repo which are not published to any repository any where. They are listed in the optionalDeps in the package.json but when I try to install in my Dockerfile it fails.
I feel like running the combination yarn install --production --ignore-optional
should ignore any resolution errors and just move on.
Or even better a --ignore-resolution-errors
flag.
Any update?
It would be nice to find away to make this work. I have a number of private packages that are used in a mono-repo which are not published to any repository any where. They are listed in the optionalDeps in the package.json but when I try to install in my Dockerfile it fails.
I feel like running the combination
yarn install --production --ignore-optional
should ignore any resolution errors and just move on.Or even better a
--ignore-resolution-errors
flag.
Would love to see this.