[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eArtifact Registry supports Node.js packages managed with npm, allowing users to store and manage their packages efficiently.\u003c/p\u003e\n"],["\u003cp\u003enpm scopes are essential for grouping packages, especially when working with multiple registries, and it's highly recommended to set a scope for each repository.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003e.npmrc\u003c/code\u003e configuration file is used to store authentication settings and define the repositories you want to connect to within Artifact Registry.\u003c/p\u003e\n"],["\u003cp\u003eStoring Artifact Registry credentials in the per-user configuration file ensures they are not accessible to other users, enhancing security.\u003c/p\u003e\n"],["\u003cp\u003eThe Artifact Registry credential helper, which is stored in the public npm registry, simplifies authentication without requiring any prior authentication for installation.\u003c/p\u003e\n"]]],[],null,["# Manage Node.js packages\n\nArtifact Registry supports Node.js packages that you manage with npm.\n\nOverview\n--------\n\nTo get familiar with Node.js packages in Artifact Registry, you can try the\n[quickstart](/artifact-registry/docs/nodejs/quickstart).\n\nWhen you are ready to learn more, read the following information:\n\n1. If you are new to npm, read about the following concepts:\n - [npm scopes](#scopes)\n - [the .npmrc configuration file](#npmrc)\n2. [Create a Node.js package repository](/artifact-registry/docs/repositories/create-repos) for your packages.\n3. [Grant permissions](/artifact-registry/docs/access-control) to the account that will connect with the repository. Service accounts for common integrations with Artifact Registry have default [permissions](/artifact-registry/docs/access-control#gcp) for repositories in the same project.\n4. Configure your tools:\n - [Configure authentication](/artifact-registry/docs/nodejs/authentication) for npm.\n - [Configure Cloud Build](/artifact-registry/docs/configure-cloud-build) to upload and download packages.\n - Learn about [deploying](/artifact-registry/docs/deploy) to Google Cloud runtime environments.\n5. [Learn about managing packages](/artifact-registry/docs/nodejs/manage-packages).\n\nUsing scopes\n------------\n\nAn npm scope is a label for grouping packages. Scopes are necessary when you\nare working with multiple npm registries, including:\n\n- Publishing and installing packages in different registries without the need to switch from one registry to another. For example, your builds might include packages from both the public npm registry and an Artifact Registry repository.\n- Publishing the same packages to multiple Artifact Registry repositories across Google Cloud projects, as well as other npm registries, without package name conflicts.\n\nWe recommend that you always set a scope for your repositories. If you do not\nspecify a scope when you publish or install package, npm uses the configured\ndefault registry, such as the public npm registry.\n\nYou set the scope for each Artifact Registry repository in the\n`.npmrc` configuration file. The same credentials for authentication apply\nacross the repositories.\n\nThe following example shows configuration for two Artifact Registry\nrepositories in different projects.\n\n- The `@blue` scope is for the repository in the project `blue-project`.\n- The `@green` scope is for the repository in the project `green-project`.\n\n @blue:registry=https://us-central1-npm.pkg.dev/blue-project/blue-npm-repo/\n //us-central1-npm.pkg.dev/blue-project/blue-npm-repo/:always-auth=true\n\n @green:registry=https://us-central1-npm.pkg.dev/green-project/green-npm-repo/\n //us-central1-npm.pkg.dev/green-project/green-npm-repo/:_authToken=\"\"\n //us-central1-npm.pkg.dev/green-project/green-npm-repo/:always-auth=true\n\nAfter you have authenticated to Artifact Registry, you can upload a package\nto a particular repository using the appropriate scope. For example, the\nfollowing command uploads a package to the `blue-npm-repo` in the project\n`blue-project`: \n\n npm publish @blue/blue-npm-repo\n\nFor more information about scopes, see the [npm documentation](https://docs.npmjs.com/using-npm/scope.html)\n\nConfiguring npm\n---------------\n\nSettings used for authentication are stored in the `.npmrc` configuration file.\nYou can configure an `.npmrc` file at the project, user, or global level.\n\nWhen you configure authentication with Artifact Registry, you define\nthe repositories that you want to connect to and the credentials for\nauthentication.\n\nArtifact Registry repositories\n\n: We recommend setting the repository list in the *per-project config file* .\n This file is usually in the same directory as the `package.json` file in your\n npm project. The Artifact Registry credential helper checks this `.npmrc`\n file for your repositories by default.\n\n If you do not want to expose the repository paths in your source control\n system, you can:\n\n - Add the `.npmrc` filename your source control's list of files to ignore.\n - Store the repository list in your per-user confg file instead. The per-user `.npmrc` file is in your user home directory, or is set with the npm `--userconfig` parameter or `$NPM_CONFIG_USERCONFIG` environment variable. Settings in the per-user config file apply to all your projects unless you override them at the project level.\n\nArtifact Registry credentials\n\n: Store your credentials for Artifact Registry in the *per-user config\n file* so that they are not available to other users. This file is located in\n your user home directory, or is set with the npm `--userconfig` parameter or\n `$NPM_CONFIG_USERCONFIG` environment variable.\n\n: The Artifact Registry\n [credential helper](https://www.npmjs.com/package/google-artifactregistry-auth) is stored in the public npm registry and does not require\n authentication for installation.\n\nYou should retain any existing default registry configured in your `.npmrc` file.\nThe default is typically set to the public npm registry at\n`https://registry.npmjs.org/`.\n\nTo check the current default registry value run the command: \n\n npm get registry\n\nFor more information about npm configuration files, see the\n[npm config file](https://docs.npmjs.com/files/npmrc)\ndocumentation."]]