yarn

remove a package

C:\>yarn remove exec-bin
yarn remove v1.22.19
[1/2] Removing module exec-bin...
[2/2] Regenerating lockfile and installing missing dependencies...
success Uninstalled packages.
Done in 2.69s.

add a package to optional dependencies

C:\>yarn add exec-bin --optional
yarn add v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ exec-bin@1.0.0
info All dependencies
└─ exec-bin@1.0.0

Success!
Done in 10.53s.

install dependencies by excluding the optional ones

The yarn install command is used to install all of the dependencies defined in a package.json file. The --ignore-optional flag tells Yarn to ignore optional dependencies.

Optional dependencies are dependencies that are specified in a package’s optionalDependencies field in the package.json file, rather than in the dependencies field. These dependencies are not required for the package to function, but may provide additional functionality. By using the --ignore-optional flag, you are telling Yarn to only install the required dependencies and to skip installing the optional dependencies.


C:\>yarn install --ignore-optional                                                                                        
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
$ (node -e "if (! require('fs').existsSync('./node_modules/hugo-installer')) { process.exit(1) } " && hugo-installer --version otherDependencies.hugo --extended --destination node_modules/.bin/hugo) || echo "hugo-installer not installed, skipping hugo installation"
"hugo-installer not installed, skipping hugo installation"
Done in 5.66s.

See also:
[^] https://classic.yarnpkg.com/en/docs/dependency-types#toc-optionaldependencies