Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 4, 2024 via pnpm

cosmiconfig 7.1.0

Find and load configuration from a package.json property, rc file, or CommonJS module
Package summary
Share
0
issues
2
licenses
23
MIT
2
ISC
Package created
12 Nov 2015
Version published
12 Nov 2022
Maintainers
2
Total deps
25
Direct deps
5
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
23 Packages, Including:
@babel/code-frame@7.24.2
@babel/helper-validator-identifier@7.22.20
@babel/highlight@7.24.2
@types/parse-json@4.0.2
ansi-styles@3.2.1
callsites@3.1.0
chalk@2.4.2
color-convert@1.9.3
color-name@1.1.3
cosmiconfig@7.1.0
error-ex@1.3.2
escape-string-regexp@1.0.5
has-flag@3.0.0
import-fresh@3.3.0
is-arrayish@0.2.1
js-tokens@4.0.0
json-parse-even-better-errors@2.3.1
lines-and-columns@1.2.4
parent-module@1.0.1
parse-json@5.2.0
path-type@4.0.0
resolve-from@4.0.0
supports-color@5.5.0

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
2 Packages, Including:
picocolors@1.0.0
yaml@1.10.2
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

5
All Dependencies CSV
β“˜ This is a list of cosmiconfig 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
@types/parse-json4.0.21.53 kBMIT
prod
import-fresh3.3.02.28 kBMIT
prod
parse-json5.2.02.53 kBMIT
prod
path-type4.0.01.97 kBMIT
prod
yaml1.10.293.03 kBISC
prod

Visualizations

Frequently Asked Questions

What does cosmiconfig do?

Cosmiconfig is a powerful tool in JavaScript ecosystem designed to search for and load configuration for your application. It brings smart default configurations while offering flexibility to customize as per your needs. It loads configuration from multiple sources such as package.json properties, JSON or YAML files, TypeScript modules, and more. Its search functionality starts looking at a specified point and moves up the directory tree, searching for acceptable configurations. If no configuration options are discovered, the program reaches up to the home directory.

How do you use cosmiconfig?

To use cosmiconfig, you first need to install it with npm:

npm install cosmiconfig

Then, you can import it into your JavaScript or TypeScript file and start using its functionalities. Given below is an example of how to use cosmiconfig for loading and searching configuration:

const { cosmiconfig, cosmiconfigSync } = require('cosmiconfig');
const explorer = cosmiconfig('yourModuleName');

// Search for a configuration:
explorer.search()
  .then(result => {
    // The result object contains these properties:
    // result.config is the parsed configuration.
    // result.filepath is the configuration file path.
    // result.isEmpty indicates if the file was empty.
  })
  .catch((error) => {
    // Handle errors
  });

// Load a configuration:
explorer.load('pathToConfig').then(result => { /*...*/ });

// For synchronous operations, you can use the cosmiconfigSync() function.

In code, 'yourModuleName' and 'pathToConfig' should be replaced with the name of your module and the desired path you want to load configuration from respectively.

Where are the cosmiconfig docs?

Cosmiconfig provides detailed documentation and comprehensive APIs for all its features that can be accessed through the Cosmiconfig Git Repository. The main sections of interest within the docs are: Installation, APIs for tooling developers, Explaining result of searching and loading, Asynchronous and Synchronous APIs, and Customizing cosmiconfig options.