check-installed
v3.2.0
Published
Minimal Node package to check that dependencies are installed ✅
Maintainers
Readme
check-installed
Minimal Node package to check that dependencies are installed ✅
Install
$ npm i check-installed --save-devChecks
Engines Check
- Compares the installed version of engines to the versions specified in
package.json - Engines can be things like node, dotnet, or anything that responds to
--version - Versions are checked with semver, so you can use any valid semver range
"engines": {
"node": ">=12.x",
"npm": ">=6",
"dotnet": "^6.0.410"
},Modules Check
- Compares the installed versions of node modules to the versions specified in
package.json - Versions for modules that have
latestare not checked, only that they are installed - Optional node module dependencies are only checked if they are installed
- URL, Git URL, and file path versions are currently skipped
Usage
CLI
Run check-installed before npm scripts or directly to ensure that the environment is set up correctly.
If any check fails, the process will throw and exit with a non-zero exit code.
NPM Scripts
You can add a check script and run with npm run check or call it from other commands:
"scripts": {
"check": "check-installed",
"start": "npm run check && node index.js",
"test": "npm run check && jest"
}This repo actually uses check-installed directly 🤯.
Command Line
npx check-installedAPI
You can call the checks directly from node programatically if needed like:
const { checkEngines, checkModules } = require('check-installed')
const json = require('./package.json')
await checkEngines(json)
await checkModules(json)
await checkEngines(json, { showEngines: true })
await checkModules(json, { showSuccess: true })Each check returns a Promise<void> that throws if any check fails.
They are typed to accept the entire options object, but only use options they need.
Options
- All options are optional and will be defaulted
- CLI formats to change default values:
boolean:true:--option-nameor--option-name=truefalse:--option-name=falseor--option-name=or--option-name=anythingelse
string:--option-name=value
- Options for
checkEnginesandcheckModulesare the same as CLI options butcamelCased
--help
Show help (skips check)
Type: boolean, Default: false
--skip-engines
Skip checking engines
Type: boolean, Default: false
--skip-modules
Skip checking node modules
Type: boolean, Default: false
--show-success
Show success message on successful checks
Type: boolean, Default: false
--show-engines
Show installed engines on successful check
Type: boolean, Default: false
--show-modules
Show installed node modules on successful check
Type: boolean, Default: false
