Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Even after specifying the --ignore-optional flag on yarn add, it tries to install optional dependency.
If the current behavior is a bug, please provide the steps to reproduce.
(under windows)
mkdir test && cd test
npm init -y
yarn add paper --ignore-optional
What is the expected behavior?
Yarn shouldn't warn about installing the optional canvas dependency, when I don't have the tools to build it.
Please mention your node.js, yarn and operating system version.
Node: 6.9.2
Yarn: 0.19.1
Windows 10 Home 64bit
I am experiencing this same issue. No errors are thrown, and the optional dependencies are still installed and added to yarn.lock.
Isn't the flag --no-optional?
yarn add --help gives me:

I think that may be wrong since the docs on the site state it's --no-optional and that's the flag npm uses.
Actually, I can't even find the word optional on the website docs here: https://yarnpkg.com/en/docs/cli/install#search. Plus, there is no entry for no-optional in the yarn help command.
merging into https://github.com/yarnpkg/yarn/issues/2666
This is still an issue with yarn v1.1.0, running yarn add --help | grep opt I see:
--ignore-optional ignore optional dependencies
-O, --optional save package to your `optionalDependencies`
I can find it in the CLI help documentation, but not the yarn website docs. When I do:
yarn add --ignore-optional [email protected]
yarn why dtrace-provider
I can verify that the optional dtrace-provider dependency is installed anyways. As a result, I can't ignore optional dependencies for a specific package.
Like @timrs2998, I'm seeing the same issue on yarn 1.2.1 (Mac, 10.13). Comments added to #4665.
--ignore-optional works in yarn 1.15.2 on MacBookPro12,1 with node 11.13.0
--ignore-optional does not work in yarn 1.15.2 on MacBookPro 10.14.5 with node 11.13.0
$ yarn install --ignore-optional
yarn install v1.15.2
[1/4] ๐ Resolving packages...
error Package "" refers to a non-existing file '"/Users/rodrigosilveira/projects/rms-sparklines/dist/rmstek-sparklines"'.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
rodrigosilveira@Rodrigos-MacBook-Air[~/projects/rms-sparklines]
$ node --version
v11.13.0
rodrigosilveira@Rodrigos-MacBook-Air[~/projects/rms-sparklines]
does not work...
[I] jkassis@Jeremys-MBP ~/c/m/a/s/code (wip)> yarn add --ignore-optional rrule 11.05 07:18
yarn add v1.22.4
[1/5] ๐ Validating package.json...
[2/5] ๐ Resolving packages...
[3/5] ๐ Fetching packages...
[4/5] ๐ Linking dependencies...
[5/5] ๐จ Building fresh packages...
success Saved lockfile.
success Saved 3 new dependencies.
info Direct dependencies
โโ [email protected]
info All dependencies
โโ [email protected]
โโ [email protected]
โโ [email protected]
โจ Done in 0.95s.
Most helpful comment
Like @timrs2998, I'm seeing the same issue on yarn 1.2.1 (Mac, 10.13). Comments added to #4665.