Options
All
  • Public
  • Public/Protected
  • All
Menu

Package plugin-npm

@yarnpkg/plugin-npm

This plugin adds support for downloading packages from the npm registry.

Install

This plugin is included by default in Yarn.

Type aliases

CachedMetadata

CachedMetadata: object

Type declaration

  • Optional etag?: undefined | string
  • Optional lastModified?: undefined | string
  • metadata: PackageMetadata

GetPackageMetadataOptions

GetPackageMetadataOptions: Omit<Options, "ident" | "configuration"> & object

Options

Options: httpUtils.Options & RegistryOptions & object

PackageMetadata

PackageMetadata: object

Type declaration

  • dist-tags: Record<string, string>
  • versions: Record<string, object & object>

PublishAdditionalParams

PublishAdditionalParams: object

Type declaration

  • access: string | undefined
  • Optional gitHead?: undefined | string
  • registry: string
  • tag: string

RegistryOptions

RegistryOptions: object | object

Variables

Const CACHED_FIELDS

CACHED_FIELDS: ["name", "dist.tarball", "bin", "scripts", "os", "cpu", "libc", "dependencies", "dependenciesMeta", "optionalDependencies", "peerDependencies", "peerDependenciesMeta", "deprecated"] = [`name`,`dist.tarball`,`bin`,`scripts`,`os`,`cpu`,`libc`,`dependencies`,`dependenciesMeta`,`optionalDependencies`,`peerDependencies`,`peerDependenciesMeta`,`deprecated`,] as const

Const CACHE_KEY

CACHE_KEY: string = hashUtils.makeHash(...CACHED_FIELDS).slice(0, 6)

Used to invalidate the on-disk cache when the format changes.

Const NODE_GYP_IDENT

NODE_GYP_IDENT: Ident = structUtils.makeIdent(null, `node-gyp`)

Const NODE_GYP_MATCH

NODE_GYP_MATCH: RegExp = /\b(node-gyp|prebuild-install)\b/

Const PACKAGE_METADATA_CACHE

PACKAGE_METADATA_CACHE: Map<string & object, object | Promise<object>> = new Map<IdentHash, Promise<PackageMetadata> | PackageMetadata>()

Const PROTOCOL

PROTOCOL: "npm:" = `npm:`

Functions

askForOtp

  • askForOtp(error: any, __namedParameters: object): Promise<string>

customPackageError

  • customPackageError(error: RequestError, configuration: Configuration): null | string

del

  • del(path: string, __namedParameters: object): Promise<Buffer>

get

  • get(path: string, __namedParameters: object): Promise<any>

getAuditRegistry

  • getAuditRegistry(__namedParameters: object): string

getAuthConfiguration

  • getAuthConfiguration(registry: string, __namedParameters: object): MapLike

getAuthenticationHeader

  • getAuthenticationHeader(registry: string, __namedParameters: object): Promise<null | string>

getDefaultRegistry

  • getDefaultRegistry(__namedParameters: object): string

getGitHead

  • getGitHead(workingDir: PortablePath): Promise<undefined | string>

getIdentUrl

  • getIdentUrl(ident: Ident): string

getMetadataFolder

  • getMetadataFolder(configuration: Configuration): string & object

getOtpHeaders

  • getOtpHeaders(otp: string): object

getPackageMetadata

  • Caches and returns the package metadata for the given ident.

    Note: This function only caches and returns specific fields from the metadata. If you need other fields, use the uncached get or consider whether it would make more sense to extract the fields from the on-disk packages using the linkers or from the fetch results using the fetchers.

    Note: This function only caches and returns specific fields from the metadata. If you need other fields, use the uncached get or consider whether it would make more sense to extract the fields from the on-disk packages using the linkers or from the fetch results using the fetchers.

    Parameters

    • ident: Ident
    • __namedParameters: object
      • cache: undefined | Cache
      • headers: undefined | object
      • project: Project
      • registry: undefined | string
      • rest: rest
      • version: undefined | string

    Returns Promise<PackageMetadata>

getPublishAccess

getPublishRegistry

  • getPublishRegistry(manifest: Manifest, __namedParameters: object): string

getReadmeContent

  • getReadmeContent(workspace: Workspace): Promise<string>

getRegistryConfiguration

  • getRegistryConfiguration(registry: string, __namedParameters: object): MapLike | null

getRegistryFolder

  • getRegistryFolder(configuration: Configuration, registry: string): string & object

getScopeConfiguration

  • getScopeConfiguration(scope: string | null, __namedParameters: object): MapLike | null

getScopeRegistry

  • getScopeRegistry(scope: string | null, __namedParameters: object): string

handleInvalidAuthenticationError

  • handleInvalidAuthenticationError(error: any, __namedParameters: object): Promise<void>
  • Consumes all 401 Unauthorized errors and reports them as AUTHENTICATION_INVALID.

    It doesn't handle 403 Forbidden, as the npm registry uses it when the user attempts a prohibited action, such as publishing a package with a similar name to an existing package.

    It doesn't handle 403 Forbidden, as the npm registry uses it when the user attempts a prohibited action, such as publishing a package with a similar name to an existing package.

    Parameters

    • error: any
    • __namedParameters: object
      • attemptedAs: undefined | string
      • configuration: Configuration
      • headers: undefined | object
      • registry: string

    Returns Promise<void>

isOtpError

  • isOtpError(error: any): any

Const makeConfiguration

makePublishBody

  • makePublishBody(workspace: Workspace, buffer: Buffer, __namedParameters: object): Promise<object>

normalizeRegistry

  • normalizeRegistry(registry: string): string

normalizeRegistry

  • normalizeRegistry(configuration: Configuration, __namedParameters: object): string

pickPackageMetadata

post

  • post(path: string, body: httpUtils.Body, __namedParameters: object): Promise<Buffer>

put

  • put(path: string, body: httpUtils.Body, __namedParameters: object): Promise<Buffer>

shouldAuthenticate

whoami

  • whoami(registry: string, headers: object | undefined, __namedParameters: object): Promise<any>

Object literals

Const authSettings

authSettings: object

npmAlwaysAuth

npmAlwaysAuth: object

default

default: boolean = false

description

description: string = `URL of the selected npm registry (note: npm enterprise isn't supported)`

type

type: BOOLEAN = SettingsType.BOOLEAN as const

npmAuthIdent

npmAuthIdent: object

default

default: null = null

description

description: string = `Authentication identity for the npm registry (_auth in npm and yarn v1)`

type

type: SECRET = SettingsType.SECRET as const

npmAuthToken

npmAuthToken: object

default

default: null = null

description

description: string = `Authentication token for the npm registry (_authToken in npm and yarn v1)`

type

type: SECRET = SettingsType.SECRET as const

Const plugin

plugin: object

fetchers

fetchers: (NpmSemverFetcher | NpmHttpFetcher)[] = [NpmHttpFetcher,NpmSemverFetcher,]

resolvers

resolvers: (NpmSemverResolver | NpmTagResolver)[] = [NpmRemapResolver,NpmSemverResolver,NpmTagResolver,]

configuration

configuration: object

npmRegistries

npmRegistries: object

description

description: string = `Settings per registry`

normalizeKeys

normalizeKeys: normalizeRegistry = npmConfigUtils.normalizeRegistry

type

type: MAP = SettingsType.MAP

valueDefinition

valueDefinition: object

description

description: string = ``

type

type: SHAPE = SettingsType.SHAPE

properties

properties: object

npmScopes

npmScopes: object

description

description: string = `Settings per package scope`

type

type: MAP = SettingsType.MAP

valueDefinition

valueDefinition: object

description

description: string = ``

type

type: SHAPE = SettingsType.SHAPE

properties

properties: object

Const registrySettings

registrySettings: object

npmAuditRegistry

npmAuditRegistry: object

default

default: null = null

description

description: string = `Registry to query for audit reports`

type

type: STRING = SettingsType.STRING as const

npmPublishRegistry

npmPublishRegistry: object

default

default: null = null

description

description: string = `Registry to push packages to`

type

type: STRING = SettingsType.STRING as const

npmRegistryServer

npmRegistryServer: object

default

default: string = `https://registry.yarnpkg.com`

description

description: string = `URL of the selected npm registry (note: npm enterprise isn't supported)`

type

type: STRING = SettingsType.STRING as const

Generated using TypeDoc