Published on

Fixing ShadCN UI Commands Not Working on Terminal

Authors
  • Name
    Ripal & Zalak
    Twitter

Introduction

If your ShadCN UI commands have suddenly stopped working and you’re seeing errors like:

sh: line 1: shadcn-ui: command not found

or similar, don’t worry—this is likely due to recent updates in the ShadCN UI library. In this guide, we’ll explain why this happens and how to fix it using the new CLI structure.

The Problem

The ShadCN UI library recently updated its CLI tool, changing the name from shadcn-ui to shadcn. This change has caused older commands to fail, as the old CLI is no longer available.

Example of a Non-Working Command:

npx shadcn-ui@latest add button

Error:

sh: line 1: shadcn-ui: command not found

The Solution

Step 1: Use the New CLI Name

The new name for the ShadCN UI CLI is simply shadcn. Update your commands accordingly.

Example:

To initialize a project:

npx shadcn@latest init

To add components like a button:

npx shadcn@latest add button

Step 2: Install the CLI Globally (Optional)

If you frequently use the ShadCN CLI, you can install it globally for convenience:

npm install -g shadcn

After installing globally, you can use it without npx:

shadcn init
shadcn add button

Step 3: Verify Your Setup

Ensure everything is set up correctly by initializing a project and adding a component:

  1. Initialize the project:

    npx shadcn@latest init
    
  2. Add a button component:

    npx shadcn@latest add button
    

If the commands complete successfully, your ShadCN UI library is properly configured.

Additional Tips

If You’re Using a Monorepo

For monorepo setups, specify the working directory using the -c option:

npx shadcn@latest add button -c ./apps/your-app

Troubleshooting High-Severity Issues

If you encounter dependency issues (e.g., related to lodash.template):

  1. Run:
    npm audit fix --force
    
  2. Reinitialize the project:
    npx shadcn@latest init
    

Conclusion

The ShadCN UI team’s decision to rename their CLI tool simplifies its usage but requires updating older commands. By following the steps in this guide, you can resolve any issues and continue using ShadCN UI effectively. Always refer to the official documentation for the latest updates.

Have questions or run into further issues? Share them in the comments below!