Authenticating to GitHub Packages
You need an access token to publish, install, and delete packages. Du kannst ein persönliches Zugriffstoken verwenden, um Dich mit Deinem Benutzernamen direkt bei GitHub Packages oder beim GitHub-API zu authentifizieren. When you create a personal access token, you can assign the token different scopes depending on your needs.
To authenticate using a GitHub Actions-workflow:
- For package registries (
PACKAGE-REGISTRY.pkg.github.com/OWNER/REPOSITORY/IMAGE-NAME), you can use aGITHUB_TOKEN. - For the container registry (
ghcr.io/OWNER/IMAGE-NAME), you must use a personal access token.
Authenticating with a personal access token
Du musst ein persönliches Zugriffstoken mit dem entsprechenden Geltungsbereich verwenden, um Pakete in GitHub Packages zu veröffentlichen und zu installieren. Weitere Informationen findest Du unter „Über GitHub Packages."
You can authenticate to GitHub Packages with npm by either editing your per-user ~/.npmrc file to include your personal access token or by logging in to npm on the command line using your username and personal access token.
To authenticate by adding your personal access token to your ~/.npmrc file, edit the ~/.npmrc file for your project to include the following line, replacing TOKEN with your personal access token. Create a new ~/.npmrc file if one doesn't exist.
//npm.pkg.github.com/:_authToken=TOKEN
To authenticate by logging in to npm, use the npm login command, replacing USERNAME with your GitHub username, TOKEN with your personal access token, and PUBLIC-EMAIL-ADDRESS with your email address.
$ npm login --registry=https://npm.pkg.github.com
> Username: USERNAME
> Password: TOKEN
> Email: PUBLIC-EMAIL-ADDRESS
Authenticating with the GITHUB_TOKEN
Wenn Du einen GitHub Actions-Workflow verwendest, kannst Du einen GITHUB_TOKEN verwenden, um Pakete in GitHub Packages zu veröffentlichen und zu konsumieren, ohne einen persönlichen Zugriffstoken speichern und verwalten zu müssen. Weitere Informationen findest Du unter „Authentifizieren mit dem GITHUB_TOKEN."
Publishing a package
By default, GitHub Packages publishes a package in the GitHub repository you specify in the name field of the package.json file. For example, you would publish a package named @my-org/test to the my-org/test GitHub repository. You can add a summary for the package listing page by including a README.md file in your package directory. For more information, see "Working with package.json" and "How to create Node.js Modules" in the npm documentation.
You can publish multiple packages to the same GitHub repository by including a URL field in the package.json file. For more information, see "Publishing multiple packages to the same repository."
You can set up the scope mapping for your project using either a local .npmrc file in the project or using the publishConfig option in the package.json. GitHub Packages only supports scoped npm packages. Scoped packages have names with the format of @owner/name. Scoped packages always begin with an @ symbol. You may need to update the name in your package.json to use the scoped name. For example, "name": "@codertocat/hello-world-npm".
Nachdem Du ein Paket veröffentlicht hast, kannst Du das Paket auf GitHub ansehen. Weitere Informationen findest Du unter „Anzeigen von Paketen."
Publishing a package using a local .npmrc file
You can use an .npmrc file to configure the scope mapping for your project. In the .npmrc file, use the GitHub Packages URL and account owner so GitHub Packages knows where to route package requests. Using an .npmrc file prevents other developers from accidentally publishing the package to npmjs.org instead of GitHub Packages. Da keine Großbuchstaben unterstützt werden, musst Du für das Namensfeld Kleinbuchstaben verwenden, auch dann, wenn Dein GitHub-Benutzer- oder Organisationsname Großbuchstaben enthält.
-
Authentifizieren bei GitHub Packages. Weitere Informationen findest Du unter „Bei GitHub Packages authentifizieren“.
-
Erstelle oder bearbeite eine
.npmrcDatei im gleichen Verzeichnis wie Deinepackage.jsonDatei, um eine Zeile mit der GitHub Packages-URL und dem Kontoinhaber einzufügen. ErsetzeOWNERdurch den Namen des Benutzer- oder Organisationskonto, welches das Repository besitzt, in dem sich Dein Projekt befindet.registry=https://npm.pkg.github.com/OWNER -
Füge die .npmrc Datei in das Repository hinzu, wo GitHub Packages Dein Projekt finden kann. Weitere Informationen findest Du unter „Eine Datei über die Befehlszeile einem Repository hinzufügen."
-
Verify the name of your package in your project's package.json. The
namefield must contain the scope and the name of the package. For example, if your package is called "test", and you are publishing to the "My-org" GitHub organization, thenamefield in your package.json should be@my-org/test. -
Überprüfe das
repositoryFeld in der Datei package.json Deines Projekts. DasrepositoryFeld muss mit der URL für Dein GitHub Repository übereinstimmen. Wenn Deine Repository-URL beispielsweisegithub.com/my-org/testist, sollte das Repository-Feldgit://github.com/my-org/test.gitsein. -
Das Paket veröffentlichen:
$ npm publish
Publishing a package using publishConfig in the package.json file
You can use publishConfig element in the package.json file to specify the registry where you want the package published. For more information, see "publishConfig" in the npm documentation.
-
Edit the package.json file for your package and include a
publishConfigentry."publishConfig": { "registry":"https://npm.pkg.github.com" }, -
Überprüfe das
repositoryFeld in der Datei package.json Deines Projekts. DasrepositoryFeld muss mit der URL für Dein GitHub Repository übereinstimmen. Wenn Deine Repository-URL beispielsweisegithub.com/my-org/testist, sollte das Repository-Feldgit://github.com/my-org/test.gitsein. -
Das Paket veröffentlichen:
$ npm publish
Publishing multiple packages to the same repository
To publish multiple packages to the same repository, you can include the URL of the GitHub repository in the repository field of the package.json file for each package.
To ensure the repository's URL is correct, replace REPOSITORY with the name of the repository containing the package you want to publish, and OWNER with the name of the user or organization account on GitHub that owns the repository.
GitHub Packages will match the repository based on the URL, instead of based on the package name. If you store the package.json file outside the root directory of your repository, you can use the directory field to specify the location where GitHub Packages can find the package.json files.
"repository" : {
"type" : "git",
"url": "ssh://git@github.com/OWNER/REPOSITORY.git",
"directory": "packages/name"
},
Installing a package
You can install packages from GitHub Packages by adding the packages as dependencies in the package.json file for your project. For more information on using a package.json in your project, see "Working with package.json" in the npm documentation.
By default, you can add packages from one organization. For more information, see "Installing packages from other organizations."
You also need to add the .npmrc file to your project so all requests to install packages will go through GitHub Packages. When you route all package requests through GitHub Packages, you can use both scoped and unscoped packages from npmjs.com. For more information, see "npm-scope" in the npm documentation.
-
Authentifizieren bei GitHub Packages. Weitere Informationen findest Du unter „Bei GitHub Packages authentifizieren“.
-
Erstelle oder bearbeite eine
.npmrcDatei im gleichen Verzeichnis wie Deinepackage.jsonDatei, um eine Zeile mit der GitHub Packages-URL und dem Kontoinhaber einzufügen. ErsetzeOWNERdurch den Namen des Benutzer- oder Organisationskonto, welches das Repository besitzt, in dem sich Dein Projekt befindet.registry=https://npm.pkg.github.com/OWNER -
Füge die .npmrc Datei in das Repository hinzu, wo GitHub Packages Dein Projekt finden kann. Weitere Informationen findest Du unter „Eine Datei über die Befehlszeile einem Repository hinzufügen."
-
Configure package.json in your project to use the package you are installing. To add your package dependencies to the package.json file for GitHub Packages, specify the full-scoped package name, such as
@my-org/server. For packages from npmjs.com, specify the full name, such as@babel/coreor@lodash. For example, this following package.json uses the@octo-org/octo-apppackage as a dependency.{ "name": "@my-org/server", "version": "1.0.0", "description": "Server app that uses the @octo-org/octo-app package", "main": "index.js", "author": "", "license": "MIT", "dependencies": { "@octo-org/octo-app": "1.0.0" } } -
Install the package.
$ npm install
Installing packages from other organizations
By default, you can only use GitHub Packages packages from one organization. If you'd like to route package requests to multiple organizations and users, you can add additional lines to your .npmrc file, replacing OWNER with the name of the user or organization account that owns the repository containing your project. Da keine Großbuchstaben unterstützt werden, musst Du für das Namensfeld Kleinbuchstaben verwenden, auch dann, wenn Dein GitHub-Benutzer- oder Organisationsname Großbuchstaben enthält.
registry=https://npm.pkg.github.com/OWNER
@OWNER:registry=npm.pkg.github.com
@OWNER:registry=npm.pkg.github.com

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
