Yarn: Does `yarn add --ignore-optional` work?

Created on 10 Feb 2017  ยท  11Comments  ยท  Source: yarnpkg/yarn

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

Most helpful comment

Like @timrs2998, I'm seeing the same issue on yarn 1.2.1 (Mac, 10.13). Comments added to #4665.

All 11 comments

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:

image

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.

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.
Was this page helpful?
0 / 5 - 0 ratings