node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

192
server/node_modules/package-json/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,192 @@
import {Agent as HttpAgent} from 'http';
import {Agent as HttpsAgent} from 'https';
declare class VersionNotFoundErrorClass extends Error {
readonly name: 'VersionNotFoundError';
constructor(packageName: string, version: string);
}
declare class PackageNotFoundErrorClass extends Error {
readonly name: 'PackageNotFoundError';
constructor(packageName: string);
}
declare namespace packageJson {
interface Agents {
http?: HttpAgent;
https?: HttpsAgent;
}
interface Options {
/**
Package version such as `1.0.0` or a [dist tag](https://docs.npmjs.com/cli/dist-tag) such as `latest`.
The version can also be in any format supported by the [semver](https://github.com/npm/node-semver) module. For example:
- `1` - Get the latest `1.x.x`
- `1.2` - Get the latest `1.2.x`
- `^1.2.3` - Get the latest `1.x.x` but at least `1.2.3`
- `~1.2.3` - Get the latest `1.2.x` but at least `1.2.3`
@default 'latest'
*/
readonly version?: string;
/**
By default, only an abbreviated metadata object is returned for performance reasons. [Read more.](https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md)
@default false
*/
readonly fullMetadata?: boolean;
/**
Return the [main entry](https://registry.npmjs.org/ava) containing all versions.
@default false
*/
readonly allVersions?: boolean;
/**
The registry URL is by default inferred from the npm defaults and `.npmrc`. This is beneficial as `package-json` and any project using it will work just like npm. This option is*only** intended for internal tools. You should*not** use this option in reusable packages. Prefer just using `.npmrc` whenever possible.
*/
readonly registryUrl?: string;
/**
Overwrite the `agent` option that is passed down to [`got`](https://github.com/sindresorhus/got#agent). This might be useful to add [proxy support](https://github.com/sindresorhus/got#proxies).
*/
readonly agent?: HttpAgent | HttpsAgent | Agents | false;
}
interface FullMetadataOptions extends Options {
/**
By default, only an abbreviated metadata object is returned for performance reasons. [Read more.](https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md)
@default false
*/
readonly fullMetadata: true;
}
interface DistTags {
readonly [tagName: string]: string;
readonly latest: string;
}
interface AbbreviatedMetadata {
readonly [key: string]: unknown;
readonly 'dist-tags': DistTags;
readonly modified: string;
readonly name: string;
readonly versions: Readonly<Record<string, AbbreviatedVersion>>;
}
interface AbbreviatedVersion {
readonly [key: string]: unknown;
readonly name: string;
readonly version: string;
readonly dist: {
readonly shasum: string;
readonly tarball: string;
readonly integrity?: string;
};
readonly deprecated?: string;
readonly dependencies?: Readonly<Record<string, string>>;
readonly optionalDependencies?: Readonly<Record<string, string>>;
readonly devDependencies?: Readonly<Record<string, string>>;
readonly bundleDependencies?: Readonly<Record<string, string>>;
readonly peerDependencies?: Readonly<Record<string, string>>;
readonly bin?: Readonly<Record<string, string>>;
readonly directories?: readonly string[];
readonly engines?: Readonly<Record<string, string>>;
readonly _hasShrinkwrap?: boolean;
}
interface Person {
readonly name?: string;
readonly email?: string;
readonly url?: string;
}
interface HoistedData {
readonly author?: Person;
readonly bugs?:
| {readonly url: string; readonly email?: string}
| {readonly url?: string; readonly email: string};
readonly contributors?: readonly Person[];
readonly description?: string;
readonly homepage?: string;
readonly keywords?: readonly string[];
readonly license?: string;
readonly maintainers?: readonly Person[];
readonly readme?: string;
readonly readmeFilename?: string;
readonly repository?: {readonly type: string; readonly url: string};
}
interface FullMetadata extends AbbreviatedMetadata, HoistedData {
readonly [key: string]: unknown;
readonly _id: string;
readonly _rev: string;
readonly time: {
readonly [version: string]: string;
readonly created: string;
readonly modified: string;
};
readonly users?: Readonly<Record<string, boolean>>;
readonly versions: Readonly<Record<string, FullVersion>>;
}
interface FullVersion extends AbbreviatedVersion, HoistedData {
readonly [key: string]: unknown;
readonly _id: string;
readonly _nodeVersion: string;
readonly _npmUser: string;
readonly _npmVersion: string;
readonly main?: string;
readonly files?: readonly string[];
readonly man?: readonly string[];
readonly scripts?: Readonly<Record<string, string>>;
readonly gitHead?: string;
readonly types?: string;
readonly typings?: string;
}
type VersionNotFoundError = VersionNotFoundErrorClass;
type PackageNotFoundError = PackageNotFoundErrorClass;
}
declare const packageJson: { // eslint-disable-line no-redeclare
/**
Get metadata of a package from the npm registry.
@param packageName - Name of the package.
@example
```
import packageJson = require('package-json');
console.log(await packageJson('ava'));
//=> {name: 'ava', ...}
// Also works with scoped packages
console.log(await packageJson('@sindresorhus/df'));
```
*/
(packageName: string, options: packageJson.FullMetadataOptions): Promise<packageJson.FullMetadata>;
(packageName: string, options?: packageJson.Options): Promise<packageJson.AbbreviatedMetadata>;
/**
The error thrown when the given package version cannot be found.
*/
VersionNotFoundError: typeof VersionNotFoundErrorClass;
/**
The error thrown when the given package name cannot be found.
*/
PackageNotFoundError: typeof PackageNotFoundErrorClass;
// TODO: remove this in the next major version
default: typeof packageJson;
};
export = packageJson;

111
server/node_modules/package-json/index.js generated vendored Normal file
View File

@@ -0,0 +1,111 @@
'use strict';
const {Agent: HttpAgent} = require('http');
const {Agent: HttpsAgent} = require('https');
const got = require('got');
const registryUrl = require('registry-url');
const registryAuthToken = require('registry-auth-token');
const semver = require('semver');
// These agent options are chosen to match the npm client defaults and help with performance
// See: `npm config get maxsockets` and #50
const agentOptions = {
keepAlive: true,
maxSockets: 50
};
const httpAgent = new HttpAgent(agentOptions);
const httpsAgent = new HttpsAgent(agentOptions);
class PackageNotFoundError extends Error {
constructor(packageName) {
super(`Package \`${packageName}\` could not be found`);
this.name = 'PackageNotFoundError';
}
}
class VersionNotFoundError extends Error {
constructor(packageName, version) {
super(`Version \`${version}\` for package \`${packageName}\` could not be found`);
this.name = 'VersionNotFoundError';
}
}
const packageJson = async (packageName, options) => {
options = {
version: 'latest',
...options
};
const scope = packageName.split('/')[0];
const registryUrl_ = options.registryUrl || registryUrl(scope);
const packageUrl = new URL(encodeURIComponent(packageName).replace(/^%40/, '@'), registryUrl_);
const authInfo = registryAuthToken(registryUrl_.toString(), {recursive: true});
const headers = {
accept: 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*'
};
if (options.fullMetadata) {
delete headers.accept;
}
if (authInfo) {
headers.authorization = `${authInfo.type} ${authInfo.token}`;
}
const gotOptions = {
headers,
agent: {
http: httpAgent,
https: httpsAgent
}
};
if (options.agent) {
gotOptions.agent = options.agent;
}
let data;
try {
data = await got(packageUrl, gotOptions).json();
} catch (error) {
if (error.response.statusCode === 404) {
throw new PackageNotFoundError(packageName);
}
throw error;
}
if (options.allVersions) {
return data;
}
let {version} = options;
const versionError = new VersionNotFoundError(packageName, version);
if (data['dist-tags'][version]) {
data = data.versions[data['dist-tags'][version]];
} else if (version) {
if (!data.versions[version]) {
const versions = Object.keys(data.versions);
version = semver.maxSatisfying(versions, version);
if (!version) {
throw versionError;
}
}
data = data.versions[version];
if (!data) {
throw versionError;
}
}
return data;
};
module.exports = packageJson;
// TODO: remove this in the next major version
module.exports.default = packageJson;
module.exports.PackageNotFoundError = PackageNotFoundError;
module.exports.VersionNotFoundError = VersionNotFoundError;

9
server/node_modules/package-json/license generated vendored Normal file
View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,146 @@
# Change Log
All notable changes will be documented in this file.
## [4.2.2] - 2022-06-16
### Changes
- Pin version of `rc` module to `1.2.8` to avoid malware in [compromised versions](https://github.com/advisories/GHSA-g2q5-5433-rhrf) (Espen Hovlandsdal)
## [4.2.1] - 2020-11-10
### Changes
- Exclude tests from published npm files (Garrit Franke)
## [4.2.0] - 2020-07-13
### Changes
- Add support for `NPM_CONFIG_USERCONFIG` environment variable (Ben Sorohan)
## [4.1.0] - 2020-01-17
### Changes
- Add support for legacy auth token on the registry url (Gustav Blomér)
## [4.0.0] - 2019-06-17
### BREAKING
- Minimum node.js version requirement is now v6
### Changes
- Upgraded dependencies (Espen Hovlandsdal)
## [3.4.0] - 2019-03-20
### Changes
- Enabled legacy auth token to be read from environment variable (Martin Flodin)
## [3.3.2] - 2018-01-26
### Changes
- Support password with ENV variable tokens (Nowell Strite)
## [3.3.1] - 2017-05-02
### Fixes
- Auth legacy token is basic auth (Hutson Betts)
## [3.3.0] - 2017-04-24
### Changes
- Support legacy auth token config key (Zoltan Kochan)
- Use safe-buffer module for backwards-compatible base64 encoding/decoding (Espen Hovlandsdal)
- Change to standard.js coding style (Espen Hovlandsdal)
## [3.2.0] - 2017-04-20
### Changes
- Allow passing parsed npmrc from outside (Zoltan Kochan)
## [3.1.2] - 2017-04-07
### Changes
- Avoid infinite loop on invalid URL (Zoltan Kochan)
## [3.1.1] - 2017-04-06
### Changes
- Nerf-dart URLs even if recursive is set to false (Espen Hovlandsdal)
## [3.1.0] - 2016-10-19
### Changes
- Return the password and username for Basic authorization (Zoltan Kochan)
## [3.0.1] - 2016-08-07
### Changes
- Fix recursion bug (Lukas Eipert)
- Implement alternative base64 encoding/decoding implementation for Node 6 (Lukas Eipert)
## [3.0.0] - 2016-08-04
### Added
- Support for Basic Authentication (username/password) (Lukas Eipert)
### Changes
- The result format of the output changed from a simple string to an object which contains the token type
```js
// before: returns 'tokenString'
// after: returns {token: 'tokenString', type: 'Bearer'}
getAuthToken()
```
## [2.1.1] - 2016-07-10
### Changes
- Fix infinite loop when recursively resolving registry URLs on Windows (Espen Hovlandsdal)
## [2.1.0] - 2016-07-07
### Added
- Add feature to find configured registry URL for a scope (Espen Hovlandsdal)
## [2.0.0] - 2016-06-17
### Changes
- Fix tokens defined by reference to environment variables (Dan MacTough)
## [1.1.1] - 2016-04-26
### Changes
- Fix for registries with port number in URL (Ryan Day)
[1.1.1]: https://github.com/rexxars/registry-auth-token/compare/a5b4fe2f5ff982110eb8a813ba1b3b3c5d851af1...v1.1.1
[2.0.0]: https://github.com/rexxars/registry-auth-token/compare/v1.1.1...v2.0.0
[2.1.0]: https://github.com/rexxars/registry-auth-token/compare/v2.0.0...v2.1.0
[2.1.1]: https://github.com/rexxars/registry-auth-token/compare/v2.1.0...v2.1.1
[3.0.0]: https://github.com/rexxars/registry-auth-token/compare/v2.1.1...v3.0.0
[3.0.1]: https://github.com/rexxars/registry-auth-token/compare/v3.0.0...v3.0.1
[3.1.0]: https://github.com/rexxars/registry-auth-token/compare/v3.0.1...v3.1.0
[3.1.1]: https://github.com/rexxars/registry-auth-token/compare/v3.1.0...v3.1.1
[3.1.2]: https://github.com/rexxars/registry-auth-token/compare/v3.1.1...v3.1.2
[3.2.0]: https://github.com/rexxars/registry-auth-token/compare/v3.1.2...v3.2.0
[3.3.0]: https://github.com/rexxars/registry-auth-token/compare/v3.2.0...v3.3.0

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Espen Hovlandsdal
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,65 @@
# registry-auth-token
[![npm version](http://img.shields.io/npm/v/registry-auth-token.svg?style=flat-square)](http://browsenpm.org/package/registry-auth-token)[![Build Status](http://img.shields.io/travis/rexxars/registry-auth-token/main.svg?style=flat-square)](https://travis-ci.org/rexxars/registry-auth-token)
Get the auth token set for an npm registry from `.npmrc`. Also allows fetching the configured registry URL for a given npm scope.
## Installing
```
npm install --save registry-auth-token
```
## Usage
Returns an object containing `token` and `type`, or `undefined` if no token can be found. `type` can be either `Bearer` or `Basic`.
```js
var getAuthToken = require('registry-auth-token')
var getRegistryUrl = require('registry-auth-token/registry-url')
// Get auth token and type for default `registry` set in `.npmrc`
console.log(getAuthToken()) // {token: 'someToken', type: 'Bearer'}
// Get auth token for a specific registry URL
console.log(getAuthToken('//registry.foo.bar'))
// Find the registry auth token for a given URL (with deep path):
// If registry is at `//some.host/registry`
// URL passed is `//some.host/registry/deep/path`
// Will find token the closest matching path; `//some.host/registry`
console.log(getAuthToken('//some.host/registry/deep/path', {recursive: true}))
// Find the configured registry url for scope `@foobar`.
// Falls back to the global registry if not defined.
console.log(getRegistryUrl('@foobar'))
// Use the npm config that is passed in
console.log(getRegistryUrl('http://registry.foobar.eu/', {
npmrc: {
'registry': 'http://registry.foobar.eu/',
'//registry.foobar.eu/:_authToken': 'qar'
}
}))
```
## Return value
```js
// If auth info can be found:
{token: 'someToken', type: 'Bearer'}
// Or:
{token: 'someOtherToken', type: 'Basic'}
// Or, if nothing is found:
undefined
```
## Security
Please be careful when using this. Leaking your auth token is dangerous.
## License
MIT-licensed. See LICENSE.

View File

@@ -0,0 +1,12 @@
function decodeBase64 (base64) {
return Buffer.from(base64, 'base64').toString('utf8')
}
function encodeBase64 (string) {
return Buffer.from(string, 'utf8').toString('base64')
}
module.exports = {
decodeBase64: decodeBase64,
encodeBase64: encodeBase64
}

View File

@@ -0,0 +1,142 @@
var url = require('url')
var base64 = require('./base64')
var decodeBase64 = base64.decodeBase64
var encodeBase64 = base64.encodeBase64
var tokenKey = ':_authToken'
var legacyTokenKey = ':_auth'
var userKey = ':username'
var passwordKey = ':_password'
module.exports = function () {
var checkUrl
var options
if (arguments.length >= 2) {
checkUrl = arguments[0]
options = arguments[1]
} else if (typeof arguments[0] === 'string') {
checkUrl = arguments[0]
} else {
options = arguments[0]
}
options = options || {}
options.npmrc = options.npmrc || require('rc')('npm', { registry: 'https://registry.npmjs.org/' }, {
config: process.env.npm_config_userconfig || process.env.NPM_CONFIG_USERCONFIG
})
checkUrl = checkUrl || options.npmrc.registry
return getRegistryAuthInfo(checkUrl, options) || getLegacyAuthInfo(options.npmrc)
}
function getRegistryAuthInfo (checkUrl, options) {
var parsed = url.parse(checkUrl, false, true)
var pathname
while (pathname !== '/' && parsed.pathname !== pathname) {
pathname = parsed.pathname || '/'
var regUrl = '//' + parsed.host + pathname.replace(/\/$/, '')
var authInfo = getAuthInfoForUrl(regUrl, options.npmrc)
if (authInfo) {
return authInfo
}
// break if not recursive
if (!options.recursive) {
return /\/$/.test(checkUrl)
? undefined
: getRegistryAuthInfo(url.resolve(checkUrl, '.'), options)
}
parsed.pathname = url.resolve(normalizePath(pathname), '..') || '/'
}
return undefined
}
function getLegacyAuthInfo (npmrc) {
if (!npmrc._auth) {
return undefined
}
var token = replaceEnvironmentVariable(npmrc._auth)
return { token: token, type: 'Basic' }
}
function normalizePath (path) {
return path[path.length - 1] === '/' ? path : path + '/'
}
function getAuthInfoForUrl (regUrl, npmrc) {
// try to get bearer token
var bearerAuth = getBearerToken(npmrc[regUrl + tokenKey] || npmrc[regUrl + '/' + tokenKey])
if (bearerAuth) {
return bearerAuth
}
// try to get basic token
var username = npmrc[regUrl + userKey] || npmrc[regUrl + '/' + userKey]
var password = npmrc[regUrl + passwordKey] || npmrc[regUrl + '/' + passwordKey]
var basicAuth = getTokenForUsernameAndPassword(username, password)
if (basicAuth) {
return basicAuth
}
var basicAuthWithToken = getLegacyAuthToken(npmrc[regUrl + legacyTokenKey] || npmrc[regUrl + '/' + legacyTokenKey])
if (basicAuthWithToken) {
return basicAuthWithToken
}
return undefined
}
function replaceEnvironmentVariable (token) {
return token.replace(/^\$\{?([^}]*)\}?$/, function (fullMatch, envVar) {
return process.env[envVar]
})
}
function getBearerToken (tok) {
if (!tok) {
return undefined
}
// check if bearer token is set as environment variable
var token = replaceEnvironmentVariable(tok)
return { token: token, type: 'Bearer' }
}
function getTokenForUsernameAndPassword (username, password) {
if (!username || !password) {
return undefined
}
// passwords are base64 encoded, so we need to decode it
// See https://github.com/npm/npm/blob/v3.10.6/lib/config/set-credentials-by-uri.js#L26
var pass = decodeBase64(replaceEnvironmentVariable(password))
// a basic auth token is base64 encoded 'username:password'
// See https://github.com/npm/npm/blob/v3.10.6/lib/config/get-credentials-by-uri.js#L70
var token = encodeBase64(username + ':' + pass)
// we found a basicToken token so let's exit the loop
return {
token: token,
type: 'Basic',
password: pass,
username: username
}
}
function getLegacyAuthToken (tok) {
if (!tok) {
return undefined
}
// check if legacy auth token is set as environment variable
var token = replaceEnvironmentVariable(tok)
return { token: token, type: 'Basic' }
}

View File

@@ -0,0 +1,48 @@
{
"name": "registry-auth-token",
"version": "4.2.2",
"description": "Get the auth token set for an npm registry (if any)",
"main": "index.js",
"scripts": {
"test": "mocha",
"posttest": "standard",
"coverage": "istanbul cover _mocha"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/rexxars/registry-auth-token.git"
},
"engines": {
"node": ">=6.0.0"
},
"keywords": [
"npm",
"conf",
"config",
"npmconf",
"registry",
"auth",
"token",
"authtoken"
],
"author": "Espen Hovlandsdal <espen@hovlandsdal.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/rexxars/registry-auth-token/issues"
},
"homepage": "https://github.com/rexxars/registry-auth-token#readme",
"dependencies": {
"rc": "1.2.8"
},
"devDependencies": {
"istanbul": "^0.4.2",
"mocha": "^6.1.4",
"require-uncached": "^1.0.2",
"standard": "^12.0.1"
},
"standard": {
"ignore": [
"coverage/**"
]
}
}

View File

@@ -0,0 +1,5 @@
module.exports = function (scope, npmrc) {
var rc = npmrc || require('rc')('npm', { registry: 'https://registry.npmjs.org/' })
var url = rc[scope + ':registry'] || rc.registry
return url.slice(-1) === '/' ? url : url + '/'
}

47
server/node_modules/package-json/package.json generated vendored Normal file
View File

@@ -0,0 +1,47 @@
{
"name": "package-json",
"version": "7.0.0",
"description": "Get metadata of a package from the npm registry",
"license": "MIT",
"repository": "sindresorhus/package-json",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=12"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"npm",
"registry",
"package",
"pkg",
"package.json",
"json",
"module",
"scope",
"scoped"
],
"dependencies": {
"got": "^11.8.2",
"registry-auth-token": "^4.0.0",
"registry-url": "^5.0.0",
"semver": "^7.3.5"
},
"devDependencies": {
"@types/node": "^15.12.4",
"ava": "^2.4.0",
"mock-private-registry": "^1.1.2",
"tsd": "^0.17.0",
"xo": "^0.39.0"
}
}

105
server/node_modules/package-json/readme.md generated vendored Normal file
View File

@@ -0,0 +1,105 @@
# package-json
> Get metadata of a package from the npm registry
## Install
```
$ npm install package-json
```
## Usage
```js
const packageJson = require('package-json');
(async () => {
console.log(await packageJson('ava'));
//=> {name: 'ava', ...}
// Also works with scoped packages
console.log(await packageJson('@sindresorhus/df'));
})();
```
## API
### packageJson(packageName, options?)
#### packageName
Type: `string`
Name of the package.
#### options
Type: `object`
##### version
Type: `string`\
Default: `latest`
Package version such as `1.0.0` or a [dist tag](https://docs.npmjs.com/cli/dist-tag) such as `latest`.
The version can also be in any format supported by the [semver](https://github.com/npm/node-semver) module. For example:
- `1` - Get the latest `1.x.x`
- `1.2` - Get the latest `1.2.x`
- `^1.2.3` - Get the latest `1.x.x` but at least `1.2.3`
- `~1.2.3` - Get the latest `1.2.x` but at least `1.2.3`
##### fullMetadata
Type: `boolean`\
Default: `false`
By default, only an abbreviated metadata object is returned for performance reasons. [Read more.](https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md)
##### allVersions
Type: `boolean`\
Default: `false`
Return the [main entry](https://registry.npmjs.org/ava) containing all versions.
##### registryUrl
Type: `string`\
Default: Auto-detected
The registry URL is by default inferred from the npm defaults and `.npmrc`. This is beneficial as `package-json` and any project using it will work just like npm. This option is **only** intended for internal tools. You should **not** use this option in reusable packages. Prefer just using `.npmrc` whenever possible.
##### agent
Type: `http.Agent | https.Agent | object | false`
Overwrite the `agent` option that is passed down to [`got`](https://github.com/sindresorhus/got#agent). This might be useful to add [proxy support](https://github.com/sindresorhus/got#proxies).
### packageJson.PackageNotFoundError
The error thrown when the given package name cannot be found.
### packageJson.VersionNotFoundError
The error thrown when the given package version cannot be found.
## Authentication
Both public and private registries are supported, for both scoped and unscoped packages, as long as the registry uses either bearer tokens or basic authentication.
## package-json for enterprise
Available as part of the Tidelift Subscription.
The maintainers of package-json and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-package-json?utm_source=npm-package-json&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
## Related
- [package-json-cli](https://github.com/sindresorhus/package-json-cli) - CLI for this module
- [latest-version](https://github.com/sindresorhus/latest-version) - Get the latest version of an npm package
- [pkg-versions](https://github.com/sindresorhus/pkg-versions) - Get the version numbers of a package from the npm registry
- [npm-keyword](https://github.com/sindresorhus/npm-keyword) - Get a list of npm packages with a certain keyword
- [npm-user](https://github.com/sindresorhus/npm-user) - Get user info of an npm user
- [npm-email](https://github.com/sindresorhus/npm-email) - Get the email of an npm user