1. optional-dev-dependency
try to install an optional development dependency, YOLO if you can't.
optional-dev-dependency
Package: optional-dev-dependency
Created by: bcoe
Last modified: Mon, 03 Jul 2023 20:59:32 GMT
Version: 2.0.1
License: ISC
Downloads: 1,977
Repository: https://github.com/bcoe/optional-dev-dependency

Install

npm install optional-dev-dependency
yarn add optional-dev-dependency

optional-dev-dependency

Build Status
Coverage Status
NPM version
js-standard-style

For when you want to try to install a module, but want to keep on truckin'
if you are unable to. I found this useful for simulating optional-dev-dependencies.

 optional-dev-dependency lodash [email protected] fffffffgggggg

All different npm install styles are supported besides the git remote url

Command Line

optional-dev-dependency package [options]

Options:
  -s, --silent   should the `npm install` output be shown?
                                                      [boolean] [default: false]
  -S, --save     try to install the specified packages, and save them to
                 optionalDevDependencies in package.json
                                                      [boolean] [default: false]
  -t, --tag      only try to load dependencies with this tag
  -V, --verbose  output NPM commands before running them
                                                      [boolean] [default: false]
  -h, --help     Show help                                             [boolean]
  -v, --version  Show version number                                   [boolean]

Examples:
  ../bin/odd.js lodash hiredis  try to install 'lodash' and 'hiredis', it's okay
                                if an install fails.
  ../bin/odd.js -t travis       try to install optionalDevDependencies for the
                                'travis' tag from package.json, it's okay if an
                                install fails.

Examples

Here's an example from node_redis:

 {
  "name": "redis",
  "scripts": {
    "pretest": "optional-dev-dependency hiredis"
  }
}

You can also save optionalDevDependencies in your package.json file for ease
of installation later. For example, let's say you want most developers who
download your package and play with it to run basic tests, but when you run your
code on your continuous integration server, you need a few extra dependencies.
You can use a package.json file like this:

 {
  "name": "sample",
  "scripts": {
    "test": "mocha",
    "precoverage": "optional-dev-dependency",
    "coverage": "nyc npm test",
    "preci": "optional-dev-dependency -t ci",
    "ci": "nyc report --reporter=text-lcov | coveralls"
  },
  "optionalDevDependencies": {
    "nyc": "^8.3.1",
    "coveralls": [
      "^2.11.14",
      "ci"
    ]
  }
}

When you do npm run coverage, the precoverage script will ensure that all
optionalDevDependencies without a tag are installed (in this case, nyc).

When you do npm run ci on your CI server, the preci script will ensure that
all optionalDevDependencies with the ci tag are installed (in this case,
coveralls).

You can load optionalDevDependencies into your package.json with the
--save/-S flag. This will install the latest lodash, save that version
in your package.json, and will only install it later if the foo or bar
tag is specified:

 optional-dev-dependency --save lodash -t foo -t bar

License

ISC

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code