
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
rc-config-loader
Advanced tools
Load config from .{product}rc.{json,yml,js} file.
It is a Node.js library for loading .textlintrc, .eslintrc, .stylelintrc etc...
Find and load a configuration object from:
package.json property if it is needed.<product>rc or .<product>rc.json or .<product>rc.js or.<product>rc.yml, .<product>rc.yaml.d.tsrc contains shabang in .js filesync optionInstall with npm:
npm install rc-config-loader
export interface rcConfigLoaderOption {
// does look for `package.json`
packageJSON?: boolean,
// if config file name is not same with packageName, set the name
configFileName?: string;
// treat default(no ext file) as some extension
defaultExtension?: string | string[],
// where start to load
cwd?: string;
}
export default function rcConfigLoader(packageName: string, options?: rcConfigLoaderOption): Object;
rcConfigLoader return { config, filePath } object.
config: it is config objectfilePath: absolute path to config fileIf not found config file, return undefined.
"use strict";
const rcfile = require("rc-config-loader");
// load .eslintrc from current dir
console.log(rcfile("eslint"));
// load .eslintrc from specific path
console.log(rcfile("eslint", {
configFileName: `${__dirname}/test/fixtures/.eslintrc`
}));
/*
config: { extends: 'standard',
rules:
{ 'comma-dangle': [ 2, 'always-multiline' ],
'arrow-parens': [ 2, 'as-needed' ] } }
filePath: ${__dirname}/test/fixtures/.eslintrc
*/
// load property from pacakge.json
console.log(rcfile("rc-config-loader", {
packageJSON: {
fieldName: "directories"
}
}));
/*
config: { test: 'test' }
filePath: /path/to/package.json
*/
// load .eslintrc from specific dir
console.log(rcfile("eslint", {
cwd: `${__dirname}/test/fixtures`
}));
// load specific filename from current dir
console.log(rcfile("travis", {configFileName: ".travis"}));
/*
config: { sudo: false, language: 'node_js', node_js: 'stable' }
filePath: /path/to/.travis
*/
// try to load as .json, .yml, js
console.log(rcfile("bar", {
configFileName: `${__dirname}/test/fixtures/.barrc`,
defaultExtension: [".json", ".yml", ".js"]
}));
// try to load as .yml, but it is not json
// throw Error
try {
rcfile("unknown", {
// This is not json
configFileName: `${__dirname}/test/fixtures/.unknownrc`,
defaultExtension: ".json"
})
} catch (error) {
console.log(error);
/*
SyntaxError: Cannot read config file: /test/fixtures/.unknownrc
*/
}
See Releases page.
Install devDependencies and Run npm test:
npm i -d && npm test
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
git checkout -b my-new-featuregit commit -am 'Add some feature'git push origin my-new-featureMIT © azu
Difference
defaultExtensionCosmiconfig is a versatile configuration loader that searches for configuration files in various formats (JSON, YAML, JS, etc.) and locations. It offers more flexibility and customization options compared to rc-config-loader.
The config package provides a more structured approach to configuration management, supporting environment-specific configurations and hierarchical settings. It is more feature-rich but also more complex than rc-config-loader.
Dotenv is a simpler package focused on loading environment variables from a .env file into process.env. While it doesn't support multiple file formats or complex configurations, it is very useful for managing environment-specific settings.
FAQs
load config file from .{product}rc.{json,yml,js}
The npm package rc-config-loader receives a total of 1,157,148 weekly downloads. As such, rc-config-loader popularity was classified as popular.
We found that rc-config-loader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.