code.gitea.io/gitea@v1.22.3/docs/content/usage/packages/npm.en-us.md (about)

     1  ---
     2  date: "2021-07-20T00:00:00+00:00"
     3  title: "npm Package Registry"
     4  slug: "npm"
     5  sidebar_position: 70
     6  draft: false
     7  toc: false
     8  menu:
     9    sidebar:
    10      parent: "packages"
    11      name: "npm"
    12      sidebar_position: 70
    13      identifier: "npm"
    14  ---
    15  
    16  # npm Package Registry
    17  
    18  Publish [npm](https://www.npmjs.com/) packages for your user or organization.
    19  
    20  ## Requirements
    21  
    22  To work with the npm package registry, you need [Node.js](https://nodejs.org/en/download/) coupled with a package manager such as [Yarn](https://classic.yarnpkg.com/en/docs/install) or [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm/) itself.
    23  
    24  The registry supports [scoped](https://docs.npmjs.com/misc/scope/) and unscoped packages.
    25  
    26  The following examples use the `npm` tool with the scope `@test`.
    27  
    28  ## Configuring the package registry
    29  
    30  To register the package registry you need to configure a new package source.
    31  
    32  ```shell
    33  npm config set {scope}:registry=https://gitea.example.com/api/packages/{owner}/npm/
    34  npm config set -- '//gitea.example.com/api/packages/{owner}/npm/:_authToken' "{token}"
    35  ```
    36  
    37  | Parameter    | Description |
    38  | ------------ | ----------- |
    39  | `scope`      | The scope of the packages. |
    40  | `owner`      | The owner of the package. |
    41  | `token`      | Your [personal access token](development/api-usage.md#authentication). |
    42  
    43  For example:
    44  
    45  ```shell
    46  npm config set @test:registry=https://gitea.example.com/api/packages/testuser/npm/
    47  npm config set -- '//gitea.example.com/api/packages/testuser/npm/:_authToken' "personal_access_token"
    48  ```
    49  
    50  or without scope:
    51  
    52  ```shell
    53  npm config set registry https://gitea.example.com/api/packages/testuser/npm/
    54  npm config set -- '//gitea.example.com/api/packages/testuser/npm/:_authToken' "personal_access_token"
    55  ```
    56  
    57  ## Publish a package
    58  
    59  Publish a package by running the following command in your project:
    60  
    61  ```shell
    62  npm publish
    63  ```
    64  
    65  You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.
    66  
    67  ## Unpublish a package
    68  
    69  Delete a package by running the following command:
    70  
    71  ```shell
    72  npm unpublish {package_name}[@{package_version}]
    73  ```
    74  
    75  | Parameter         | Description |
    76  | ----------------- | ----------- |
    77  | `package_name`    | The package name. |
    78  | `package_version` | The package version. |
    79  
    80  For example:
    81  
    82  ```shell
    83  npm unpublish @test/test_package
    84  npm unpublish @test/test_package@1.0.0
    85  ```
    86  
    87  ## Install a package
    88  
    89  To install a package from the package registry, execute the following command:
    90  
    91  ```shell
    92  npm install {package_name}
    93  ```
    94  
    95  | Parameter      | Description |
    96  | -------------- | ----------- |
    97  | `package_name` | The package name. |
    98  
    99  For example:
   100  
   101  ```shell
   102  npm install @test/test_package
   103  ```
   104  
   105  ## Tag a package
   106  
   107  The registry supports [version tags](https://docs.npmjs.com/adding-dist-tags-to-packages/) which can be managed by `npm dist-tag`:
   108  
   109  ```shell
   110  npm dist-tag add {package_name}@{version} {tag}
   111  ```
   112  
   113  | Parameter      | Description |
   114  | -------------- | ----------- |
   115  | `package_name` | The package name. |
   116  | `version`      | The version of the package. |
   117  | `tag`          | The tag name. |
   118  
   119  For example:
   120  
   121  ```shell
   122  npm dist-tag add test_package@1.0.2 release
   123  ```
   124  
   125  The tag name must not be a valid version. All tag names which are parsable as a version are rejected.
   126  
   127  ## Search packages
   128  
   129  The registry supports [searching](https://docs.npmjs.com/cli/v7/commands/npm-search/) but does not support special search qualifiers like `author:gitea`.
   130  
   131  ## Supported commands
   132  
   133  ```
   134  npm install
   135  npm ci
   136  npm publish
   137  npm unpublish
   138  npm dist-tag
   139  npm view
   140  npm search
   141  ```