You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 7, 2025. It is now read-only.
This command makes the following changes to your `~/.npmrc` file:
274
+
275
+
- Adds an authorization token after fetching it from CodeArtifact using your AWS credentials.
276
+
- Sets the npm registry to the repository specified by the `--repository` option.
277
+
-**For npm 6 and lower:** Adds `"always-auth=true"` so the authorization token is sent for every npm command.
278
+
279
+
The default authorization period after calling login is 12 hours, and login must be called to periodically refresh the token.
280
+
For more information about the authorization token created with the login command, see [Tokens created with the login command](https://docs.aws.amazon.com/codeartifact/latest/ug/tokens-authentication.html#auth-token-login).
281
+
282
+
### Configuring npm manually
283
+
284
+
You can configure npm with your CodeArtifact repository without the `awslocal codeartifact login` command by manually updating the npm configuration.
285
+
286
+
#### To configure npm without using the login command
287
+
288
+
1. In a command line, fetch a CodeArtifact authorization token and store it in an environment variable.
289
+
npm will use this token to authenticate with your CodeArtifact repository.
3. Use the `npm config set` command to set the registry to your CodeArtifact repository.
309
+
Replace the URL with the repository endpoint URL from the previous step.
310
+
311
+
{{< command >}}
312
+
$ npm config set registry http://demo-domain-000000000000.d.codeartifact.eu-central-1.localhost.localstack.cloud/npm/demo-repo/
313
+
{{< /command >}}
314
+
315
+
4. Use the `npm config set` command to add your authorization token to your npm configuration.
316
+
317
+
{{< command >}}
318
+
$ npm config set //demo-domain-000000000000.d.codeartifact.eu-central-1.localhost.localstack.cloud/:_authToken=${CODEARTIFACT_AUTH_TOKEN}
319
+
{{< /command >}}
320
+
321
+
**For npm 6 or lower:** To make npm always pass the auth token to CodeArtifact, even for GET requests, set the always-auth configuration variable with npm config set.
322
+
323
+
{{< command >}}
324
+
$ npm config set //demo-domain-000000000000.d.codeartifact.eu-central-1.localhost.localstack.cloud/:always-auth=true
325
+
{{< /command >}}
326
+
327
+
#### Example npm configuration file (`.npmrc`)
328
+
329
+
The following is an example `.npmrc` file after following the preceding instructions to set the CodeArtifact registry endpoint, add an authentication token, and configure `always-auth`.
0 commit comments