NPM Package Specifier Parser
Parse an NPM package spec (lodash, @scope/[email protected], github:user/repo) into name, scope, version and type.
The forms of an npm package specifier
What you write after a package name is not only a version number. npm accepts a range, a dist-tag, a git repository, a tarball URL, a local path, a GitHub shorthand and an alias — and each form resolves differently at install time. The page identifies which one you have in hand and explains what it implies.
The most useful distinction is between an exact version, a range and a dist-tag. An exact version pins; a range lets npm choose at install time; a dist-tag is a published name pointing at a version that can change without notice. There is also a real ambiguity: npm tries to read the text as a range and, failing that, as a dist-tag — so a typo in a range can turn into a search for a tag that does not exist.
The forms that skip the registry deserve attention. A git repository with no ref after the hash installs the default branch, which means the same install at two moments can bring different code. A path with file: creates a symlink rather than copying, so a change in the source folder shows up immediately — excellent in development, bad in a container image.
Frequently asked questions
What is the npm: alias for?
Is the user-slash-repository shorthand safe?
What does the lockfile change here?
Related Tools
URN Parser
Decompose a URN (urn:NID:NSS) into namespace identifier (NID) and namespace-specific string (NSS). Supports r-component and q-component (RFC 8141).
Link Header Parser
Decompose an HTTP Link header (RFC 8288) listing each URI with its parameters (rel, type, title). Useful for paginated APIs and Web Linking.
Authorization Header Parser
Identify the scheme (Basic, Bearer, Digest) of an Authorization header and extract the payload, decoding Basic from base64.
UUID Parser
Decompose a UUID into version (1, 3, 4, 5, 6, 7, 8), variant, and when applicable, timestamp and node. Supports UUIDs with or without dashes.
User-Agent Parser
Parse User-Agent strings and identify browser, version, operating system and device type. Perfect for debugging access logs.
HTTP Cookie Parser
Paste a Set-Cookie header and inspect name, value, Domain, Path, Expires, Max-Age, HttpOnly, Secure and SameSite separately. Browser-only.