NPM.Config (NPM v0.7.0)

Copy Markdown View Source

Read npm configuration from .npmrc files.

Checks for .npmrc in the project directory and home directory. Environment variables take precedence over file configuration.

Summary

Functions

Whether HTTP redirects to different registry origins are allowed.

Registry origins allowed for packuments and tarballs.

Read the auth token.

Whether transitive git, file, and URL dependencies are blocked.

Path to the bundled seed database of known malicious package reports.

Read the global package cache directory.

Path to an OSV-format database of known malicious package reports.

Policy for compromised-package findings in security tasks.

Known-compromised package intelligence sources to use.

Allowed direct exotic dependency specs.

Gets a config value with fallback to defaults.

Read the runtime install directory for NPM.install/2.

Loads config from all levels: project .npmrc then user .npmrc. Project values override user values.

Merges multiple config maps (later overrides earlier).

Read the configured registry mirror URL.

Warn when a package was created fewer than this many days ago.

Parse an .npmrc file into a map of key-value pairs.

Read a value from .npmrc files.

Read the effective registry URL.

Returns the registry URL for a given scope, or the default.

Warn when a package version was published fewer than this many days ago.

Functions

allow_registry_redirects?()

@spec allow_registry_redirects?() :: boolean()

Whether HTTP redirects to different registry origins are allowed.

allowed_registries()

@spec allowed_registries() :: [String.t()]

Registry origins allowed for packuments and tarballs.

auth_token()

@spec auth_token() :: String.t() | nil

Read the auth token.

Priority: NPM_TOKEN env var > config :npm, :token > project .npmrc > home .npmrc.

block_exotic_subdeps?()

@spec block_exotic_subdeps?() :: boolean()

Whether transitive git, file, and URL dependencies are blocked.

bundled_compromised_db_path()

@spec bundled_compromised_db_path() :: String.t()

Path to the bundled seed database of known malicious package reports.

cache_dir()

@spec cache_dir() :: String.t()

Read the global package cache directory.

compromised_db_path()

@spec compromised_db_path() :: String.t()

Path to an OSV-format database of known malicious package reports.

compromised_policy()

@spec compromised_policy() :: :error | :warn | :off

Policy for compromised-package findings in security tasks.

compromised_sources()

@spec compromised_sources() :: [atom()]

Known-compromised package intelligence sources to use.

exotic_deps()

@spec exotic_deps() :: [String.t()]

Allowed direct exotic dependency specs.

get(config, key, default \\ nil)

@spec get(map(), String.t(), term()) :: term()

Gets a config value with fallback to defaults.

install_dir(id)

@spec install_dir(String.t()) :: String.t()

Read the runtime install directory for NPM.install/2.

load(project_dir \\ ".")

@spec load(String.t()) :: map()

Loads config from all levels: project .npmrc then user .npmrc. Project values override user values.

merge(configs)

@spec merge([map()]) :: map()

Merges multiple config maps (later overrides earlier).

mirror_url()

@spec mirror_url() :: String.t()

Read the configured registry mirror URL.

package_age_warning_days()

@spec package_age_warning_days() :: non_neg_integer()

Warn when a package was created fewer than this many days ago.

parse_npmrc(content)

@spec parse_npmrc(String.t()) :: %{required(String.t()) => String.t()}

Parse an .npmrc file into a map of key-value pairs.

read_npmrc_value(key)

@spec read_npmrc_value(String.t()) :: String.t() | nil

Read a value from .npmrc files.

Checks project-level first, then home-level.

registry()

@spec registry() :: String.t()

Read the effective registry URL.

Priority: NPM_REGISTRY env var > config :npm, :registry > project .npmrc > home .npmrc > default.

scoped_registry(config, scope)

@spec scoped_registry(map(), String.t()) :: String.t()

Returns the registry URL for a given scope, or the default.

version_age_warning_days()

@spec version_age_warning_days() :: non_neg_integer()

Warn when a package version was published fewer than this many days ago.