# snyk-config

> Config setup for snyk shared across projects

Latest version **5.3.0** (published 2024-02-04) · (Apache-2.0 AND MIT) license · 0 weekly downloads

## Install

```sh
npm install snyk-config
pnpm add snyk-config
yarn add snyk-config
bun add snyk-config
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 5.3.0 |
| Published | 2024-02-04 |
| First published | 2015-10-23 |
| Weekly downloads | 0 |
| License | (Apache-2.0 AND MIT) |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 169 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Remy Sharp |
| Maintainers | snyk-admin |
| Keywords | config |

## Links

- npm: https://www.npmjs.com/package/snyk-config
- Repository: https://github.com/snyk/config
- Homepage: https://github.com/snyk/config#readme
- Issues: https://github.com/snyk/config/issues
- npm.io page: https://npm.io/package/snyk-config

## Dependencies (4)

- [async](https://npm.io/package/async.md) ^3.2.2
- [debug](https://npm.io/package/debug.md) ^4.3.4
- [minimist](https://npm.io/package/minimist.md) ^1.2.6
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.2

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 5.3.0 (latest) — 2024-02-04
- 4.0.0-rc.2 (nconffix) — 2020-11-12
- 5.2.0 — 2023-06-01
- 5.1.0 — 2022-04-14
- 5.0.0 — 2021-02-22
- 4.0.0 — 2020-11-16
- 4.0.0-rc.1 — 2020-11-11
- 3.1.1 — 2020-05-06
- 3.1.0 — 2020-04-29
- 3.0.0 — 2019-11-20
- 2.2.3 — 2019-08-05
- 2.2.2 — 2019-07-15
- 2.2.1 — 2019-02-05
- 2.2.0 — 2018-06-11
- 2.1.0 — 2018-04-28
- … 6 more at https://npm.io/package/snyk-config/versions

## README

# snyk-config

Loads the configuration for your module.


## Usage

Although you can require this module directly, it's recommended you create your
own `config.ts` file that can be cached by the require system and called *without* a path:

```typescript
// config.ts
import { loadConfig } from 'snyk-config';
export const config = loadConfig('<directory with config files>');

// in app.ts
import { config } from './config';

// in foo.ts
import { config } from './config'; // matches config in app.ts
```


## Method

The config loader will look for the following values in order of priority,
specifically, if a property appears in multiple layers of config (below) the
first found is used:

- process environment values prefixed with `SNYK_`
- process arguments
- a `config.secret.json` file in the path specified by:
   * the `secretConfig` option, or
   * the environment variable `CONFIG_SECRET_FILE`, or
   * in the specified config directory
- a `config.${SERVICE_ENV}.json` file in the specified config directory,
   * where `SERVICE_ENV` defaults to `local`, if not set
- a `config.default.json` file in the specified config directory


## Example

### config.local.json

```json
{
  "from": "file"
}
```


### app.js

```typescript
import { loadConfig } from 'snyk-config';
// as we're in the same directory as the config.local.json, there's no arg
const config = loadConfig();
console.log(config);
```


### cli

```shell
$ SNYK_from=cli node app.js
=> { from: "cli" }
```


## Notes

* Values read from the environment or from the process arguments will *always* be `strings`
  or `boolean`s. This is important to differentiate from values parsed in the config files
  as these can be `numbers`.
* Environment property names strip *off* the preceding `SNYK_` string, so `SNYK_foo = 10`
  becomes `foo = "10"`
* To create a nested object structure from the environment values, use two underscores:
  `SNYK_foo__bar = 10` becomes `foo = { bar: "10" }`
* By default, environment variable values will not be JSON-parsed.
  Parsing can be enabled by adding the `parseEnvValues` option, or by setting
  the `CONFIG_PARSE_ENV_VALUES` environment variable.

---
_Source: https://npm.io/package/snyk-config · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
