Setting up GitHub Personal Access Tokens for local development
Private NPM Package Requirements
In order to utilize your private GitHub NPM package you're going to need two things:
- A GitHub Personal Access token setup and configured for your local machine (steps below)
- A new file:
.npmrcwhich will live right next to your
package.jsonin your project repo (the codebase you're implementing your design system in). The exact file contents below:
Generating your token
- You will need to add an env variable of
$GITHUB_TOKENin order to install your private NPM package
@knapsack-cloud/[YOUR-PRIVATE-PACKAGE]in your project.
- If you run
echo $GITHUB_TOKENand do not see anything — you haven't setup your env variable
- Generate your token via this doc
export GITHUB_TOKEN="[MY TOKEN HERE]"(no square brackets or quotes) inside either your
.zshrc(you will need to
sourcethat file afterwards or completely restart the terminal)
- Open a new terminal and run
echo $GITHUB_TOKENagain to verify you see your token (if you do not you will need to close your terminal and re-open it OR source the
- Now you can
NOTE: For Windows users, we must add the environmental variable through system configuration screens.
- Open System Environment Variables
- Under the System Properties, navigate to the Advanced tab and click the bottom Environmental Variables button
- Next, in the System variables section — click the New button
- For "Variable name" use "GITHUB_TOKEN" (no quotes)
- For Variable value — paste the token you received from step 3 of the first section above.
- Click OK
- Important: restart your computer
- When the system comes back up – open Windows PowerShell and type this command:
$env:GITHUB_TOKEN— you should see your personal access token!
- Now you can