If you plan to install a package through the
instance level
, then you must name your package with a
scope
. Scoped packages begin with a
@
have the format of
@owner/package-name
. You can set up the scope for your package in the
.npmrc
file and by using the
publishConfig
option in the
package.json
.
The value used for the
@scope
is the root of the project that is hosting the packages and not the root
of the project with the source code of the package itself. The scope should be lowercase.
Replace your_domain_name with your domain name, for example, gitlab.com.
Replace your_project_id is your project ID, found on the project’s home page.
"${NPM_TOKEN}" is associated with the token you created later in the process.
Never hardcode GitLab tokens (or any tokens) directly in .npmrc files or any other files that can
be committed to a repository.
Publishing a package via the command line
Associate your token with the "${NPM_TOKEN}" in the .npmrc. Replace your_token with a deploy token, group access token, project access token, or personal access token.
NPM_TOKEN=your_token npm publish
Your package should now publish to the Package Registry.
The CLI also accepts version ranges for
@scope/package
. For example:
npm deprecate @scope/package "All package versions are deprecated"
npm deprecate @scope/package@1.0.1 "Only version 1.0.1 is deprecated"
npm deprecate @scope/package@"< 1.0.5""All package versions less than 1.0.5 are deprecated"
When you publish a package without a tag, the
latest
tag is added by default.
When you install a package without specifying the tag or version, the
latest
tag is used.
Examples of the supported
dist-tag
commands:
npm publish @scope/package --tag# Publish a package with new tag
npm dist-tag add @scope/package@version my-tag # Add a tag to an existing package
npm dist-tag ls @scope/package # List all tags under the package
npm dist-tag rm @scope/package@version my-tag # Delete a tag from the package
npm install @scope/package@my-tag # Install a specific tag
If the package and its dependencies are spread across multiple groups, you can use a
personal access token
from a user that has access to all the groups or individual projects:
Personal access tokens must be treated carefully. Read our token security considerations
for guidance on managing personal access tokens (for example, setting a short expiry and using minimal scopes).
If you didn't find what you were looking for,
search the docs
.
If you want help with something specific and could use community support,
post on the GitLab forum
.
For problems setting up or using this feature (depending on your GitLab
subscription).