Packages

cosmiconfig

10.0.1 · 30 Aug 2026MIT172.2M / weekRepositoryHomepagenpmAtom feed

Your version

6.0.0

major2 Nov 2019Where it was published

In short

5 breaking2 changed

  • breaking

    The package now has named exports. See examples below.

  • breaking

    Separate async and sync APIs, accessible from different named exports. If you used explorer.searchSync() or explorer.loadSync(), you'll now create a sync explorer with cosmiconfigSync(), then use explorerSync.search() and explorerSync.load().

  • breaking

    Remove support for Node 4 and 6. Requires Node 8+.

  • breaking

    Use npm package yaml to parse YAML instead of npm package js-yaml.

  • breaking

    Remove cosmiconfig.loaders and add named export defaultLoaders that exports the default loaders used for each extension.

Release note

  • breaking

    The package now has named exports. See examples below.

  • breaking

    Separate async and sync APIs, accessible from different named exports. If you used explorer.searchSync() or explorer.loadSync(), you'll now create a sync explorer with cosmiconfigSync(), then use explorerSync.search() and explorerSync.load().

    // OLD: cosmiconfig v5
    import cosmiconfig from 'cosmiconfig';
    
    const explorer = cosmiconfig('example');
    const searchAsyncResult = await explorer.search();
    const loadAsyncResult = await explorer.load('./file/to/load');
    const searchSyncResult = explorer.searchSync();
    const loadSyncResult = explorer.loadSync('./file/to/load');
    
    // NEW: cosmiconfig v6
    import { cosmiconfig, cosmiconfigSync } from 'cosmiconfig';
    
    const explorer = cosmiconfig('example');
    const searchAsyncResult = await explorer.search();
    const loadAsyncResult = await explorer.load('./file/to/load');
    
    const explorerSync = cosmiconfigSync('example');
    const searchSyncResult = explorerSync.search();
    const loadSyncResult = explorerSync.load('./file/to/load');
  • breaking

    Remove support for Node 4 and 6. Requires Node 8+.

  • breaking

    Use npm package yaml to parse YAML instead of npm package js-yaml.

  • breaking

    Remove cosmiconfig.loaders and add named export defaultLoaders that exports the default loaders used for each extension.

    import { defaultLoaders } from 'cosmiconfig';
    
    console.log(Object.entries(defaultLoaders));
    // [
    //   [ '.js', [Function: loadJs] ],
    //   [ '.json', [Function: loadJson] ],
    //   [ '.yaml', [Function: loadYaml] ],
    //   [ '.yml', [Function: loadYaml] ],
    //   [ 'noExt', [Function: loadYaml] ]
    // ]
  • Migrate from Flowtype to Typescript.

  • Lazy load all default loaders.