\href{https://github.com/npm/pacote}{\texttt{ {\ttfamily pacote}}} is a Node.\+js library for downloading \href{https://npmjs.org}{\texttt{ npm}}-\/compatible packages. It supports all package specifier syntax that {\ttfamily npm install} and its ilk support. It transparently caches anything needed to reduce excess operations, using \href{https://npm.im/cacache}{\texttt{ {\ttfamily cacache}}}.\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20140}{}\doxysection{Install}\label{md_sfcode_node_modules_pacote_README_autotoc_md20140}
{\ttfamily \$ npm install -\/-\/save pacote}\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20141}{}\doxysection{Table of Contents}\label{md_sfcode_node_modules_pacote_README_autotoc_md20141}

\begin{DoxyItemize}
\item \href{\#example}{\texttt{ Example}}
\item \href{\#features}{\texttt{ Features}}
\item \href{\#contributing}{\texttt{ Contributing}}
\item \href{\#api}{\texttt{ API}}
\begin{DoxyItemize}
\item \href{\#manifest}{\texttt{ {\ttfamily manifest}}}
\item \href{\#packument}{\texttt{ {\ttfamily packument}}}
\item \href{\#extract}{\texttt{ {\ttfamily extract}}}
\item \href{\#tarball}{\texttt{ {\ttfamily tarball}}}
\item \href{\#tarball-stream}{\texttt{ {\ttfamily tarball.\+stream}}}
\item \href{\#tarball-to-file}{\texttt{ {\ttfamily tarball.\+to\+File}}}
\item $\sim$$\sim$\href{\#prefetch}{\texttt{ {\ttfamily prefetch}}}$\sim$$\sim$ (deprecated)
\item \href{\#clearMemoized}{\texttt{ {\ttfamily clear\+Memoized}}}
\item \href{\#options}{\texttt{ {\ttfamily options}}}
\end{DoxyItemize}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20142}{}\doxysubsection{Example}\label{md_sfcode_node_modules_pacote_README_autotoc_md20142}

\begin{DoxyCode}{0}
\DoxyCodeLine{const pacote = require('pacote')}
\DoxyCodeLine{}
\DoxyCodeLine{pacote.manifest('pacote@\string^1').then(pkg => \{}
\DoxyCodeLine{  console.log('package manifest for registry pkg:', pkg)}
\DoxyCodeLine{  // \{ "{}name"{}: "{}pacote"{}, "{}version"{}: "{}1.0.0"{}, ... \}}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{pacote.extract('http://hi.com/pkg.tgz', './here').then(() => \{}
\DoxyCodeLine{  console.log('remote tarball contents extracted to ./here')}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20143}{}\doxysubsection{Features}\label{md_sfcode_node_modules_pacote_README_autotoc_md20143}

\begin{DoxyItemize}
\item Handles all package types \href{https://npm.im/npm}{\texttt{ npm}} does
\item \href{https://npm.im/cacache}{\texttt{ high-\/performance, reliable, verified local cache}}
\item offline mode
\item authentication support (private git, private npm registries, etc)
\item github, gitlab, and bitbucket-\/aware
\item semver range support for git dependencies
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20144}{}\doxysubsection{Contributing}\label{md_sfcode_node_modules_pacote_README_autotoc_md20144}
The pacote team enthusiastically welcomes contributions and project participation! There\textquotesingle{}s a bunch of things you can do if you want to contribute! The Contributor Guide has all the information you need for everything from reporting bugs to contributing entire new features. Please don\textquotesingle{}t hesitate to jump in if you\textquotesingle{}d like to, or even ask us questions if something isn\textquotesingle{}t clear.\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20145}{}\doxysubsection{API}\label{md_sfcode_node_modules_pacote_README_autotoc_md20145}
\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20146}{}\doxysubsubsection{$<$a name=\char`\"{}manifest\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ pacote.\+manifest(spec, \mbox{[}opts\mbox{]})$<$/tt$>$}\label{md_sfcode_node_modules_pacote_README_autotoc_md20146}
Fetches the {\itshape manifest} for a package. Manifest objects are similar and based on the {\ttfamily package.\+json} for that package, but with pre-\/processed and limited fields. The object has the following shape\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\{}
\DoxyCodeLine{  "{}name"{}: PkgName,}
\DoxyCodeLine{  "{}version"{}: SemverString,}
\DoxyCodeLine{  "{}dependencies"{}: \{ PkgName: SemverString \},}
\DoxyCodeLine{  "{}optionalDependencies"{}: \{ PkgName: SemverString \},}
\DoxyCodeLine{  "{}devDependencies"{}: \{ PkgName: SemverString \},}
\DoxyCodeLine{  "{}peerDependencies"{}: \{ PkgName: SemverString \},}
\DoxyCodeLine{  "{}bundleDependencies"{}: false || [PkgName],}
\DoxyCodeLine{  "{}bin"{}: \{ BinName: Path \},}
\DoxyCodeLine{  "{}\_resolved"{}: TarballSource, // different for each package type}
\DoxyCodeLine{  "{}\_integrity"{}: SubresourceIntegrityHash,}
\DoxyCodeLine{  "{}\_shrinkwrap"{}: null || ShrinkwrapJsonObj}
\DoxyCodeLine{\} }

\end{DoxyCode}


Note that depending on the spec type, some additional fields might be present. For example, packages from {\ttfamily registry.\+npmjs.\+org} have additional metadata appended by the registry.\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20147}{}\doxyparagraph{Example}\label{md_sfcode_node_modules_pacote_README_autotoc_md20147}

\begin{DoxyCode}{0}
\DoxyCodeLine{pacote.manifest('pacote@1.0.0').then(pkgJson => \{}
\DoxyCodeLine{  // fetched `package.json` data from the registry}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20148}{}\doxysubsubsection{$<$a name=\char`\"{}packument\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ pacote.\+packument(spec, \mbox{[}opts\mbox{]})$<$/tt$>$}\label{md_sfcode_node_modules_pacote_README_autotoc_md20148}
Fetches the {\itshape packument} for a package. Packument objects are general metadata about a project corresponding to registry metadata, and include version and {\ttfamily dist-\/tag} information about a package\textquotesingle{}s available versions, rather than a specific version. It may include additional metadata not usually available through the individual package metadata objects.

It generally looks something like this\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\{}
\DoxyCodeLine{  "{}name"{}: PkgName,}
\DoxyCodeLine{  "{}dist-\/tags"{}: \{}
\DoxyCodeLine{    'latest': VersionString,}
\DoxyCodeLine{    [TagName]: VersionString,}
\DoxyCodeLine{    ...}
\DoxyCodeLine{  \},}
\DoxyCodeLine{  "{}versions"{}: \{}
\DoxyCodeLine{    [VersionString]: Manifest,}
\DoxyCodeLine{    ...}
\DoxyCodeLine{  \}}
\DoxyCodeLine{\} }

\end{DoxyCode}


Note that depending on the spec type, some additional fields might be present. For example, packages from {\ttfamily registry.\+npmjs.\+org} have additional metadata appended by the registry.\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20149}{}\doxyparagraph{Example}\label{md_sfcode_node_modules_pacote_README_autotoc_md20149}

\begin{DoxyCode}{0}
\DoxyCodeLine{pacote.packument('pacote').then(pkgJson => \{}
\DoxyCodeLine{  // fetched package versions metadata from the registry}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20150}{}\doxysubsubsection{$<$a name=\char`\"{}extract\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ pacote.\+extract(spec, destination, \mbox{[}opts\mbox{]})$<$/tt$>$}\label{md_sfcode_node_modules_pacote_README_autotoc_md20150}
Extracts package data identified by {\ttfamily $<$spec$>$} into a directory named {\ttfamily $<$destination$>$}, which will be created if it does not already exist.

If {\ttfamily opts.\+digest} is provided and the data it identifies is present in the cache, {\ttfamily extract} will bypass most of its operations and go straight to extracting the tarball.\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20151}{}\doxyparagraph{Example}\label{md_sfcode_node_modules_pacote_README_autotoc_md20151}

\begin{DoxyCode}{0}
\DoxyCodeLine{pacote.extract('pacote@1.0.0', './woot', \{}
\DoxyCodeLine{  digest: 'deadbeef'}
\DoxyCodeLine{\}).then(() => \{}
\DoxyCodeLine{  // Succeeds as long as `pacote@1.0.0` still exists somewhere. Network and}
\DoxyCodeLine{  // other operations are bypassed entirely if `digest` is present in the cache.}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20152}{}\doxysubsubsection{$<$a name=\char`\"{}tarball\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ pacote.\+tarball(spec, \mbox{[}opts\mbox{]})$<$/tt$>$}\label{md_sfcode_node_modules_pacote_README_autotoc_md20152}
Fetches package data identified by {\ttfamily $<$spec$>$} and returns the data as a buffer.

This API has two variants\+:


\begin{DoxyItemize}
\item {\ttfamily pacote.\+tarball.\+stream(spec, \mbox{[}opts\mbox{]})} -\/ Same as {\ttfamily pacote.\+tarball}, except it returns a stream instead of a Promise.
\item {\ttfamily pacote.\+tarball.\+to\+File(spec, dest, \mbox{[}opts\mbox{]})} -\/ Instead of returning data directly, data will be written directly to {\ttfamily dest}, and create any required directories along the way.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20153}{}\doxyparagraph{Example}\label{md_sfcode_node_modules_pacote_README_autotoc_md20153}

\begin{DoxyCode}{0}
\DoxyCodeLine{pacote.tarball('pacote@1.0.0', \{ cache: './my-\/cache' \}).then(data => \{}
\DoxyCodeLine{  // data is the tarball data for pacote@1.0.0}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20154}{}\doxysubsubsection{$<$a name=\char`\"{}tarball-\/stream\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ pacote.\+tarball.\+stream(spec, \mbox{[}opts\mbox{]})$<$/tt$>$}\label{md_sfcode_node_modules_pacote_README_autotoc_md20154}
Same as {\ttfamily pacote.\+tarball}, except it returns a stream instead of a Promise.\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20155}{}\doxyparagraph{Example}\label{md_sfcode_node_modules_pacote_README_autotoc_md20155}

\begin{DoxyCode}{0}
\DoxyCodeLine{pacote.tarball.stream('pacote@1.0.0')}
\DoxyCodeLine{.pipe(fs.createWriteStream('./pacote-\/1.0.0.tgz')) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20156}{}\doxysubsubsection{$<$a name=\char`\"{}tarball-\/to-\/file\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ pacote.\+tarball.\+to\+File(spec, dest, \mbox{[}opts\mbox{]})$<$/tt$>$}\label{md_sfcode_node_modules_pacote_README_autotoc_md20156}
Like {\ttfamily pacote.\+tarball}, but instead of returning data directly, data will be written directly to {\ttfamily dest}, and create any required directories along the way.\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20157}{}\doxyparagraph{Example}\label{md_sfcode_node_modules_pacote_README_autotoc_md20157}

\begin{DoxyCode}{0}
\DoxyCodeLine{pacote.tarball.toFile('pacote@1.0.0', './pacote-\/1.0.0.tgz')}
\DoxyCodeLine{.then(() => /* pacote tarball written directly to ./pacote-\/1.0.0.tgz */) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20158}{}\doxysubsubsection{$<$a name=\char`\"{}prefetch\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ pacote.\+prefetch(spec, \mbox{[}opts\mbox{]})$<$/tt$>$}\label{md_sfcode_node_modules_pacote_README_autotoc_md20158}
\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20159}{}\doxyparagraph{THIS API IS DEPRECATED. USE $<$tt$>$pacote.\+tarball()$<$/tt$>$ INSTEAD}\label{md_sfcode_node_modules_pacote_README_autotoc_md20159}
Fetches package data identified by {\ttfamily $<$spec$>$}, usually for the purpose of warming up the local package cache (with {\ttfamily opts.\+cache}). It does not return anything.\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20160}{}\doxyparagraph{Example}\label{md_sfcode_node_modules_pacote_README_autotoc_md20160}

\begin{DoxyCode}{0}
\DoxyCodeLine{pacote.prefetch('pacote@1.0.0', \{ cache: './my-\/cache' \}).then(() => \{}
\DoxyCodeLine{  // ./my-\/cache now has both the manifest and tarball for `pacote@1.0.0`.}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20161}{}\doxysubsubsection{$<$a name=\char`\"{}clear\+Memoized\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ pacote.\+clear\+Memoized()$<$/tt$>$}\label{md_sfcode_node_modules_pacote_README_autotoc_md20161}
This utility function can be used to force pacote to release its references to any memoized data in its various internal caches. It might help free some memory.


\begin{DoxyCode}{0}
\DoxyCodeLine{pacote.manifest(...).then(() => pacote.clearMemoized)}

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20162}{}\doxysubsubsection{$<$a name=\char`\"{}options\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ options$<$/tt$>$}\label{md_sfcode_node_modules_pacote_README_autotoc_md20162}
{\ttfamily pacote} accepts \href{https://npm.im/npm-registry-fetch\#fetch-options}{\texttt{ the options for {\ttfamily npm-\/registry-\/fetch}}} as-\/is, with a couple of additional {\ttfamily pacote-\/specific} ones\+:\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20163}{}\doxyparagraph{$<$a name=\char`\"{}dir\+Packer\char`\"{}$>$$<$/a$>$ $<$tt$>$opts.\+dir\+Packer$<$/tt$>$}\label{md_sfcode_node_modules_pacote_README_autotoc_md20163}

\begin{DoxyItemize}
\item Type\+: Function
\item Default\+: Uses \href{https://npm.im/npm-packlist}{\texttt{ {\ttfamily npm-\/packlist}}} and \href{https://npm.im/tar}{\texttt{ {\ttfamily tar}}} to make a tarball.
\end{DoxyItemize}

Expects a function that takes a single argument, {\ttfamily dir}, and returns a {\ttfamily Readable\+Stream} that outputs packaged tarball data. Used when creating tarballs for package specs that are not already packaged, such as git and directory dependencies. The default {\ttfamily opts.\+dir\+Packer} does not execute {\ttfamily prepare} scripts, even though npm itself does.\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20164}{}\doxyparagraph{$<$a name=\char`\"{}opts-\/enjoy-\/by\char`\"{}$>$$<$/a$>$ $<$tt$>$opts.\+enjoy-\/by$<$/tt$>$}\label{md_sfcode_node_modules_pacote_README_autotoc_md20164}

\begin{DoxyItemize}
\item Alias\+: {\ttfamily opts.\+enjoy\+By}, {\ttfamily opts.\+before}
\item Type\+: Date-\/able
\item Default\+: undefined
\end{DoxyItemize}

If passed in, will be used while resolving to filter the versions for {\bfseries{registry dependencies}} such that versions published {\bfseries{after}} {\ttfamily opts.\+enjoy-\/by} are not considered -- as if they\textquotesingle{}d never been published.\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20165}{}\doxyparagraph{$<$a name=\char`\"{}opts-\/include-\/deprecated\char`\"{}$>$$<$/a$>$ $<$tt$>$opts.\+include-\/deprecated$<$/tt$>$}\label{md_sfcode_node_modules_pacote_README_autotoc_md20165}

\begin{DoxyItemize}
\item Alias\+: {\ttfamily opts.\+include\+Deprecated}
\item Type\+: Boolean
\item Default\+: false
\end{DoxyItemize}

If false, deprecated versions will be skipped when selecting from registry range specifiers. If true, deprecations do not affect version selection.\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20166}{}\doxyparagraph{$<$a name=\char`\"{}opts-\/full-\/metadata\char`\"{}$>$$<$/a$>$ $<$tt$>$opts.\+full-\/metadata$<$/tt$>$}\label{md_sfcode_node_modules_pacote_README_autotoc_md20166}

\begin{DoxyItemize}
\item Type\+: Boolean
\item Default\+: false
\end{DoxyItemize}

If {\ttfamily true}, the full packument will be fetched when doing metadata requests. By defaul, {\ttfamily pacote} only fetches the summarized packuments, also called \char`\"{}corgis\char`\"{}.\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20167}{}\doxyparagraph{$<$a name=\char`\"{}opts-\/tag\char`\"{}$>$$<$/a$>$ $<$tt$>$opts.\+tag$<$/tt$>$}\label{md_sfcode_node_modules_pacote_README_autotoc_md20167}

\begin{DoxyItemize}
\item Alias\+: {\ttfamily opts.\+default\+Tag}
\item Type\+: String
\item Default\+: `\textquotesingle{}latest'\`{}
\end{DoxyItemize}

Package version resolution tag. When processing registry spec ranges, this option is used to determine what dist-\/tag to treat as \char`\"{}latest\char`\"{}. For more details about how {\ttfamily pacote} selects versions and how {\ttfamily tag} is involved, see \href{https://npm.im/npm-pick-manifest}{\texttt{ the documentation for {\ttfamily npm-\/pick-\/manifest}}}.\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20168}{}\doxyparagraph{$<$a name=\char`\"{}opts-\/resolved\char`\"{}$>$$<$/a$>$ $<$tt$>$opts.\+resolved$<$/tt$>$}\label{md_sfcode_node_modules_pacote_README_autotoc_md20168}

\begin{DoxyItemize}
\item Type\+: String
\item Default\+: null
\end{DoxyItemize}

When fetching tarballs, this option can be passed in to skip registry metadata lookups when downloading tarballs. If the string is a {\ttfamily file\+:} URL, pacote will try to read the referenced local file before attempting to do any further lookups. This option does not bypass integrity checks when {\ttfamily opts.\+integrity} is passed in.\hypertarget{md_sfcode_node_modules_pacote_README_autotoc_md20169}{}\doxyparagraph{$<$a name=\char`\"{}opts-\/where\char`\"{}$>$$<$/a$>$ $<$tt$>$opts.\+where$<$/tt$>$}\label{md_sfcode_node_modules_pacote_README_autotoc_md20169}

\begin{DoxyItemize}
\item Type\+: String
\item Default\+: null
\end{DoxyItemize}

Passed as an argument to \href{https://npm.im/npm-package-arg}{\texttt{ {\ttfamily npm-\/package-\/arg}}} when resolving {\ttfamily spec} arguments. Used to determine what path to resolve local path specs relatively from. 