Setup
To develop with Hero's Elements, you will need to be provided with a Personal Access Token (PAT) and an API key. To request, please contact Hero support - make sure to specify your use case to enable us to apply the correct scopes to your key.
For more information on how to authenticate an Element using your API key, see our Auth section.
Guide: Configuring .npmrc
to Access HeroHealth packages
Once you receive your PAT token, you need to configure your .npmrc
file to authenticate and access the private packages. Follow these steps:
1. Edit the .npmrc
file
You should create or modify the .npmrc
file in the root of your project (or globally in your user directory for broader use).
In the .npmrc
file, add the following configuration:
# Use the registry for the @herohealthsoftware scope
@herohealthsoftware:registry=https://npm.pkg.github.com/
# Authentication: Use the environment variable for the PAT
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
2. How this works
- The
@herohealthsoftware:registry
line tells npm to fetch packages for the@herohealthsoftware
scope from GitHub's npm registry athttps://npm.pkg.github.com/
. - The
_authToken=${NODE_AUTH_TOKEN}
line instructs npm to use theNODE_AUTH_TOKEN
environment variable (which contains the PAT) for authentication when accessing this registry.
3. Set the NODE_AUTH_TOKEN
environment variable
For this to work, you need to set the NODE_AUTH_TOKEN
environment variable in your system to the provided PAT. Follow the instructions below to set the environment variable based on your operating system.
For Linux/macOS
Open the terminal.
Set the environment variable temporarily:
export NODE_AUTH_TOKEN=YOUR_PAT_HERE
To make the change permanent (so it's available for all future terminal sessions), you can add this line to your shell configuration file:
- For bash, add it to
~/.bashrc
:echo 'export NODE_AUTH_TOKEN=YOUR_PAT_HERE' >> ~/.bashrc \``
- For zsh, add it to
~/.zshrc
:echo 'export NODE_AUTH_TOKEN=YOUR_PAT_HERE' >> ~/.zshrc
- For bash, add it to
After modifying the shell configuration file, reload the shell to apply the changes:
source ~/.bashrc # for bash users source ~/.zshrc # for zsh users
For Windows
Open a Command Prompt or PowerShell window.
Set the environment variable temporarily for the current session:
$env:NODE_AUTH_TOKEN="YOUR_PAT_HERE"
To make the change permanent (so the token is available in all sessions), follow these steps:
- Press Win + R, type
sysdm.cpl
, and press Enter. - Go to the Advanced tab, then click Environment Variables.
- In the User variables section, click New.
- Set the Variable name to
NODE_AUTH_TOKEN
and the Variable value to your provided PAT. - Click OK to save.
- Press Win + R, type
4. Install packages
Once your .npmrc
file is configured and the PAT is set in your environment, you can now run the following command to install the private package:
npm install @herohealthsoftware/elements
npm install @herohealthsoftware/your-package-name
This command will authenticate via the NODE_AUTH_TOKEN
and fetch the package from the GitHub registry.