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 and verifying your GitHub 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. Proceed to next steps below.
- While logged into GitHub, visit your account tokens page —> create a new token
- The only permission required is
- Proceed to the sections below to store your token
export GITHUB_TOKEN="[TOKEN HERE]"(no square brackets or quotes) inside either your
- Important: You will need to
sourceyour bash profile afterwards (or completely restart the terminal).
- Open a new terminal and run
echo $GITHUB_TOKENagain —> verify you see your token.
- If you do not see your token —> revisit step 2 above.
- 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