简体   繁体   中英

Avoid installing optional deps with Yarn

In my yarn.lock file I have only one reference to momentjs:

pikaday@^1.6.0:
  version "1.6.1"
  resolved "https://registry.yarnpkg.com/pikaday/-/pikaday-1.6.1.tgz#b91bcb9b8539cedd8d6d08e4e7465e12095671b0"
  optionalDependencies:
    moment "2.x"

I delete all the node_modules folder and the yarn.lock file, and run yarn --ignore-optional but the new yarn.lock generated contains the same lines, and it installs moment in my node_modules so it gets included in my bundle.

I am running on the yarn version 0.27.5 .

How can avoid to install this dep marked as optional?

Turns out Yarn indeed lists all optional dependencies at yarn.lock . However, when --ignore-optional flag is specified those modules aren't installed into node_modules/ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM