
Security News
Security Community Slams MIT-linked Report Claiming AI Powers 80% of Ransomware
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.
configstore
Advanced tools
Easily load and persist config without having to think about where and how
The config is stored in a JSON file located in $XDG_CONFIG_HOME or ~/.config.
Example: ~/.config/configstore/some-id.json
If you need this for Electron, check out electron-store instead.
And check out conf for a more modern version of configstore.
npm install configstore
import fs from 'node:fs';
import Configstore from 'configstore';
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
// Create a Configstore instance.
const config = new Configstore(packageJson.name, {foo: 'bar'});
console.log(config.get('foo'));
//=> 'bar'
config.set('awesome', true);
console.log(config.get('awesome'));
//=> true
// Use dot-notation to access nested properties.
config.set('bar.baz', true);
console.log(config.get('bar'));
//=> {baz: true}
// Use default values with nullish coalescing
console.log(config.get('nonexistent') ?? 'default value');
//=> 'default value'
config.delete('awesome');
console.log(config.get('awesome'));
//=> undefined
Returns a new instance.
Type: string
Name of your package.
Type: object
Default config.
Type: object
Type: boolean
Default: false
Store the config at $CONFIG/package-name/config.json instead of the default $CONFIG/configstore/package-name.json. This is not recommended as you might end up conflicting with other tools, rendering the "without having to think" idea moot.
Type: string
Default: Automatic
Please don't use this option unless absolutely necessary and you know what you're doing.
Set the path of the config file. Overrides the packageName and globalConfigPath options.
Type: boolean
Default: true
Clear the config file if it contains invalid JSON. If set to false, a SyntaxError will be thrown instead of clearing the file. This allows you to recover corrupted config files manually.
You can use dot-notation in a key to access nested properties.
Set an item.
You can use dot-notation in a key to access nested properties.
Set multiple items at once.
Get an item.
You can use dot-notation in a key to access nested properties.
[!TIP] Use the nullish coalescing operator (
??) to provide default values:const value = config.get('key') ?? 'default value';
Check if an item exists.
You can use dot-notation in a key to access nested properties.
Delete an item.
You can use dot-notation in a key to access nested properties.
Delete all items.
Get the item count.
Get the path to the config file. Can be used to show the user where the config file is located or even better open it for them.
Get all the config as an object or replace the current config with an object:
config.all = {
	hello: 'world'
};
The 'rc' package is similar to configstore in that it handles configuration for Node.js applications. It reads from a variety of sources including command-line arguments, environment variables, and configuration files. Unlike configstore, 'rc' does not provide an API for setting or deleting configuration values programmatically.
The 'dotenv' package is used to load environment variables from a .env file into process.env. It is similar to configstore in that it helps manage application configuration. However, 'dotenv' is focused on environment variables and does not provide a direct API for setting, getting, or persisting data.
The 'nconf' package is a hierarchical node.js configuration with files, environment variables, command-line arguments, and atomic object merging. It provides a rich API for managing configuration data, similar to configstore, but with a focus on a hierarchical structure and multiple configuration sources.
FAQs
Easily load and save config without having to think about where and how
The npm package configstore receives a total of 10,457,968 weekly downloads. As such, configstore popularity was classified as popular.
We found that configstore 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.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.

Research
/Security News
Socket researchers found 10 typosquatted npm packages that auto-run on install, show fake CAPTCHAs, fingerprint by IP, and deploy a credential stealer.