To install npm packages from GitHub Packages, you need to provide a GitHub Personal Access Token (PAT) with the appropriate permissions.
Create new PAT token:
- Go to GitHub Settings - Developer settings - Personal access tokens
- Create new token (classic) with
read:packagesscope. - Copy the generated token.
- Set the token as an environment variable named
GH_READ_PACKAGES_TOKEN.
For powershell users, follow the instructions below to set the environment variable automatically from a .env file.
To apply .env file in windows/powershell (v7+), follow these steps:
-
Open PowerShell as Administrator.
-
Run the following command to install the pwsh-dotenv module:
Install-Module -Name pwsh-dotenv -Scope CurrentUser
-
Run the following command to open profile file in a text editor:
notepad $PROFILE -
Add the following line to the profile file to import the pwsh-dotenv module automatically:
Import-Module pwsh-dotenv if (Test-Path ".env") { Import-Dotenv ".env" }
-
Test in powershell by running:
$env:GH_READ_PACKAGES_TOKENIt should display the value of the token set in the
.envfile.