Setting up npm
To do the setting up:
-
For all projects: run this command:
npm config set registry https://registry.yandexcloud.net/npm/<registry_ID> -
For one project:
-
Open the
.npmrcfile in the project root. -
Depending on the authentication method:
IAM token (Base64)IAM tokenAPI key (Base64)-
Get an IAM token for the Yandex account or service account you are going to use for authentication.
-
Create the
NPM_AUTHenvironment variable:export NPM_AUTH=$(echo -n 'iam:<IAM_token>' | base64)Where
NPM_AUTHis the body of the previously obtained IAM token, Base64 -encoded. -
Add the following lines to the previously created
.npmrcfile:registry=https://registry.yandexcloud.net/npm/<registry_ID> //registry.yandexcloud.net/npm/:_auth=${NPM_AUTH} always-auth=true
-
Get an IAM token for the Yandex account or service account you are going to use for authentication.
-
Create the
NPM_AUTHenvironment variable:export NPM_AUTH="<IAM_token>"Where
NPM_AUTHis the body of the previously obtained IAM token. -
Add the following lines to the previously created
.npmrcfile:registry=https://registry.yandexcloud.net/npm/<registry_ID> //registry.yandexcloud.net/npm/:_authToken=${NPM_AUTH} always-auth=true
-
Create an API key for the service account you are going to use for authentication.
When creating a key, specify its scope:
yc.cloud-registry.artifacts.pull: To pull artifacts from the registry.yc.cloud-registry.artifacts.push: To push artifacts to the registry.
-
Create the
NPM_AUTHenvironment variable:export NPM_AUTH=$(echo -n 'api_key:<API_key>' | base64)Where
NPM_AUTHis the body of the previously created API key, Base64 -encoded. -
Add the following lines to the previously created
.npmrcfile:registry=https://registry.yandexcloud.net/npm/<registry_ID> //registry.yandexcloud.net/npm/:_auth=${NPM_AUTH} always-auth=true
-
-
Scope is an API key parameter that restricts the key's use to specific operations in addition to the service account's access permissions. For details, see API keys with scope and validity limits.