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:

  1. A GitHub Personal Access token setup and configured for your local machine (steps below)
  2. A new file: .npmrc which will live right next to your package.json in your project repo (the codebase you're implementing your design system in). The exact file contents below:

Generating and verifying your GitHub token

  1. You will need to add an env variable of $GITHUB_TOKEN in order to install your private NPM package @knapsack-cloud/[YOUR-PRIVATE-PACKAGE] in your project.
  2. If you run echo $GITHUB_TOKEN and do not see anything — you haven't setup your env variable. Proceed to next steps below.
  3. While logged into GitHub, visit your account tokens page —> create a new token
  4. The only permission required is read:packages
  5. Proceed to the sections below to store your token


  1. Add export GITHUB_TOKEN="[TOKEN HERE]" (no square brackets or quotes) inside either your .bash_profile , .bashrc , or .zshrc 
  2. Important: You will need to source your bash profile afterwards (or completely restart the terminal).
  3. Open a new terminal and run echo $GITHUB_TOKEN again —> verify you see your token.
  4. If you do not see your token —> revisit step 2 above.
  5. Now you can yarn install / npm install 🎉


NOTE: For Windows users, we must add the environmental variable through system configuration screens.

  1. Open System Environment Variables
  2. Under the System Properties, navigate to the Advanced tab and click the bottom Environmental Variables button

  3. Next, in the System variables section — click the New button

  4. For "Variable name" use "GITHUB_TOKEN" (no quotes)

  5. For Variable value — paste the token you received from step 3 of the first section above.
  6. Click OK
  7. Important: restart your computer
  8. When the system comes back up – open Windows PowerShell and type this command: $env:GITHUB_TOKEN — you should see your personal access token!
  9. Now you can yarn install / npm install 🎉