npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

switch-profile

v0.2.3

Published

NPX script that exposes terminal shortcut to easily switch between cloud configuration (aws, gcp).

Readme

switch-profile

An interactive CLI tool for switching between AWS profiles directly from your terminal. No more manually editing ~/.aws/credentials or juggling environment variables.

npx switch-profile

Why?

AWS SSO credentials expire every hour. Without switch-profile, refreshing them means either:

  1. Manual copy-paste - Browse to the SSO portal, log in, reveal credentials, paste them into your terminal or ~/.aws/credentials file. Repeat every hour.
  2. Per-command --profile flag - Use aws sso login --profile <name>, but then every command (and every tool like Terraform) needs --profile. Not always possible or practical.

switch-profile makes setting any AWS profile as default trivial - one command, pick from a list, done. It handles SSO session refresh automatically, including opening the browser for re-authentication when sessions expire.

Prerequisites

  • AWS CLI v2 - Version 2 or later is required.
  • Node.js - Any recent version that supports npx.

Important: Remove these environment variables from your shell if they are set, as they override the default profile and will conflict with switch-profile:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_SESSION_TOKEN

Installation

No installation needed. Run directly with npx:

npx switch-profile

Or install globally:

npm install -g switch-profile
switch-profile

Quick Start

Switch between existing profiles

npx switch-profile

This will:

  1. Show your current default profile with its expiry status.
  2. List all available profiles.
  3. Let you pick one to set as the new default.

For SSO profiles, if the session has expired, it automatically opens your browser for re-authentication.

Create a new profile

npx switch-profile
# Select "More options" > "Create profile"

You can create:

  • Standard profiles - Access key + secret key pair.
  • SSO profiles - Launches the interactive aws configure sso flow.

Delete profiles

npx switch-profile
# Select "More options" > "Delete profiles"

Select one or more profiles to remove. The current default profile cannot be deleted (switch to another one first).

Refresh an expired profile

npx switch-profile
# Select "More options" > "Refresh default profile"

This option only appears when the current default profile has expired. It forces a new SSO login and refreshes the credentials.

How It Works

switch-profile manages two AWS configuration files:

| File | Purpose | |------|---------| | ~/.aws/config | Stores profile settings (region, output format, SSO metadata) | | ~/.aws/credentials | Stores access keys, secret keys, and session tokens |

When you select a profile, switch-profile:

  1. Retrieves the credentials for that profile (from cache or via SSO login).
  2. Writes them into the [default] section of both files.
  3. Records the profile name and expiry date for status display.

For SSO profiles specifically, it leverages two additional AWS CLI cache directories:

  • ~/.aws/sso/cache/ - SSO session tokens (long-lived, ~24 hours)
  • ~/.aws/cli/cache/ - Temporary AWS credentials (short-lived, ~1 hour)

Detailed Documentation

For deeper technical details, see the docs below:

| Document | Description | |----------|-------------| | Architecture | Project structure, source files, and how the components fit together | | AWS Profile Management | How AWS profiles, SSO sessions, and credentials are managed internally | | CLI Interface | Detailed walkthrough of every menu, prompt, and user flow | | Configuration Files | Exact formats of all AWS and internal configuration files | | Development Guide | How to set up, develop, test, lint, and release |

Troubleshooting

invalid_grant: Invalid grant provided

This error occurs during SSO profile creation when the wrong SSO region is specified. AWS SSO is region-specific - you must use the region where your SSO instance is configured, not the region you want to deploy resources to.

Fix: Delete the profile and recreate it with the correct SSO region.

Error: Fail to get credentials for profile ... Error loading SSO Token...

This typically happens after the ~/.aws/sso/cache folder has been deleted or corrupted. This folder tracks SSO sessions and cannot be reconstructed automatically.

Fix: Delete the affected SSO profiles and recreate them:

  1. Run npx switch-profile
  2. Select More options > Delete profiles
  3. Remove the broken SSO profiles
  4. Recreate them via More options > Create profile

AWS CLI not found

switch-profile requires AWS CLI v2. Install it for your platform:

macOS:

brew install awscli
brew link --overwrite awscli

Linux:

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

Windows: Download and run the AWS CLI MSI installer.

License

BSD 3-Clause