Store Node.js packages in Artifact Registry
This quickstart shows you how to set up a private Artifact Registry Node.jspackage repository and upload a package to it.
Before you begin
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
- Create a project: To create a project, you need the Project Creator role (
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission.Learn how to grant roles.
If you're using an existing project for this guide,verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
Verify that billing is enabled for your Google Cloud project.
Enable the Artifact Registry API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission.Learn how to grant roles.Install the Google Cloud CLI.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Toinitialize the gcloud CLI, run the following command:
gcloudinit
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
- Create a project: To create a project, you need the Project Creator role (
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission.Learn how to grant roles.
If you're using an existing project for this guide,verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
Verify that billing is enabled for your Google Cloud project.
Enable the Artifact Registry API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission.Learn how to grant roles.Install the Google Cloud CLI.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Toinitialize the gcloud CLI, run the following command:
gcloudinit
- Install PowerShell, if you want to connect to a Node.js package repository from Windows.
Required roles
To get the permissions that you need to create and manage Artifact Registry Node.js package repositories, ask your administrator to grant you theArtifact Registry Administrator (roles/artifactregistry.admin) IAM role on your project. For more information about granting roles, seeManage access to projects, folders, and organizations.
You might also be able to get the required permissions throughcustom roles or otherpredefined roles.
Launch Cloud Shell
In this quickstart, you will useCloud Shell,which is a shell environment for managing resources hosted onGoogle Cloud.
Cloud Shell comes preinstalled with theGoogle Cloud CLI. The gcloud CLIprovides the primary command-line interface for Google Cloud.
Launch Cloud Shell:
Go to Google Cloud console.
On the Google Cloud console toolbar, clickActivate Cloud Shell:

A Cloud Shell session opens inside a frame lower on the console.You use this shell to rungcloud commands.
Create a Node.js package repository
Create the repository for your Node.js artifacts.
Create the repository.
Console
Open theRepositories page in the Google Cloud console.
ClickCreate Repository.
Specify
quickstart-nodejs-repoas the repository name.Choosenpm as the format andStandard as the mode.
UnderLocation Type, selectRegion and then choose the location
us-central1.ClickCreate.
The repository is added to the repository list
gcloud
Run the following command to create a new Node.js package repository named
quickstart-nodejs-repoin the locationus-central1with thedescription "Node.js repository".gcloudartifactsrepositoriescreatequickstart-nodejs-repo--repository-format=npm\--location=us-central1--description="Node.js package repository"Run the following command to verify that your repository was created.
gcloudartifactsrepositorieslist
For more information about Artifact Registry commands, run thecommand
gcloud artifacts.To simplify
gcloudcommands, set the default repository toquickstart-nodejs-repoand the default location tous-central1.After the values are set, you don't need to specify them ingcloudcommands that require a repository or a location.To set the repository, run the command:
gcloudconfigsetartifacts/repositoryquickstart-nodejs-repoTo set the location, run the command:
gcloudconfigsetartifacts/locationus-central1For more information about these commands, see thegcloud config set documentation.
Configure npm
To upload and download packages, you must configure your npm projects withsettings to authenticate with the repository you created. For this quickstart,you'll upload a package and then install it in a second package as adependency.
Download theemoji-regex package, a package thatprovides a regular expression to match all emoji symbols and sequences.
npmpackemoji-regexThe command downloads an archive of the package.
Extract the archive into an
emoji-regexdirectory. The following command isfor an archive ofemoji-regexversion 10.1.0:mkdiremoji-regex &&tarxvfemoji-regex-10.1.0.tgz-Cemoji-regex--strip-components1Create a second npm package that you'll use to install the
emoji-regexpackage from Artifact Registry. For this package, use thenpm initcommand to create a basic package.mkdirnpm-package2cdnpm-package2npminit-yWhen prompted, accept default values.
Configure both the
emoji-regexandnpm-package2projects to authenticatewith the Artifact Registry repository that you created.Run the following command. The command returns configuration settingsto add to your npm configuration file.
gcloudartifactsprint-settingsnpm--scope=@quickstartThe
quickstartscope is associated with your repository. When you include the scope incommands to publish or install packages, npm uses your repository. Whenyou publish or install packages without a scope, your configured defaultrepository is used. For more information, see the Node.jsoverview.The output of the
gcloudcommand looks like the following example.PROJECT is your Google Cloud project ID.@quickstart:registry=https://us-central1-npm.pkg.dev/PROJECT/quickstart-nodejs-repo///us-central1-npm.pkg.dev/PROJECT/quickstart-nodejs-repo/:always-auth=trueAdd the configuration settings from the previous step to the project
.npmrcfile in each npm project. The file in the same directoryas thepackage.jsonfile.To learn more about the
.npmrcfile, see the Node.jsoverview.Each Artifact Registry Node.js package repository is associated with an npmregistry endpoint
https://LOCATION-npm.pkg.dev/PROJECT/REPOSITORY. If you createanother Artifact Registry Node.js package repository, npm interacts with it as aseparate registry with its own scope.
Edit
package.jsonin both theemoji-regexandnpm-package2projects.Ensure that the value for
nameincludes thequickstartscope.- For
emoji-regex:
"name":"@quickstart/emoji-regex"- For
npm-package2:
"name":"@quickstart/npm-package2"- For
Under
scripts, add a script forgoogle-artifactregistry-auth, a client librarythat updates credentials for Artifact Registry repositories."scripts":{"artifactregistry-login":"npx google-artifactregistry-auth --repo-config=./.npmrc --credential-config=./.npmrc"}
Upload a package to the repository
Refresh the access token for connecting to the repository.
npmrunartifactregistry-loginAdd your package to the repository. You can use an
npmoryarncommand.npmpublishyarnpublish
View the package in the repository
To verify that your package was added to the repository:
Console
Open theRepositories page in the Google Cloud console.
In the repository list, click the
quickstart-nodejs-reporepository.ThePackages page lists the packages in the repository.
Click a package to view package versions.
gcloud
To list the images in the defaultquickstart-nodejs-repo repository, run the following command:
gcloudartifactspackageslistTo view versions for a package, run the following command:
gcloudartifactsversionslist--package=PACKAGEWherePACKAGE is the package ID.
Installing packages
Install theemoji-regex package from your Artifact Registry repositoryinnpm-package2.
In thenpm-package2 directory, run thenpm install oryarn add command:
npminstall@quickstart/emoji-regexyarnadd@quickstart/emoji-regexThe command installs theemoji-regex package in thenpm-package2 project.It also updatespackage.json to setemoji-regex as a dependency.
"dependencies":{"@quickstart/emoji-regex":"^10.1.0"}Clean up
To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.
Before you remove a repository, ensure that any packages that you want to keepare available in another location.
To delete the repository:
Console
Open theRepositories page in the Google Cloud console.
In the repository list, select the
quickstart-nodejs-reporepository.ClickDelete.
gcloud
To delete the
quickstart-nodejs-reporepository, run the followingcommand:gcloudartifactsrepositoriesdeletequickstart-nodejs-repoIf you want to remove the default repository and location settings thatyou configured for the active
gcloudconfiguration, run the followingcommands:gcloudconfigunsetartifacts/repositorygcloudconfigunsetartifacts/location
What's next
- Learn more about configuring authentication
- Learn about managing repositories
- Learn about managing packages
- Read our resources aboutDevOps and explore ourresearch program.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-19 UTC.