Simplify NPM Aliases

Simplify NPM Aliases

Published
1 min read

Table of Contents

Quick Tip

If you are a developer working with npm frequently, you might find the syntax of some commands too verbose. Fortunately, there’s an easy way to simplify them by adding a few aliases in your shell profile.

Extend Your Profile

alias npi="npm i"
alias npr="npm run"
alias npk="pkill -f node"

To add these aliases, open your shell profile file (such as ~/.bashrc or ~/.zshrc) and copy the aliases to the bottom of the file. Then, save the file and restart your terminal.

How to Use

After modifying your shell profile, you can use them in place of the longer npm commands.

For example, instead of typing npm i, you can now type npi and achieve the same result.

Similarly, instead of npm run, you can use npr. And, if you want to kill all running node processes, you can type npk instead of pkill -f node.

Here are some more examples:

  • npi -g turbo : Install Turbo globally

  • npi -D typescript : Install TypeScript to dev dependencies

  • npr dev : Run the dev script

These aliases can save you time and typing effort, especially if you use npm frequently.