Back to Ohmyzsh

npm plugin

plugins/npm/README.md

latest3.0 KB
Original Source

npm plugin

The npm plugin provides completion as well as adding many useful aliases.

To use it, add npm to the plugins array of your zshrc file:

zsh
plugins=(... npm)

Aliases

AliasCommandDescription
npmgnpm i -gInstall dependencies globally
npmSnpm i -SInstall and save to dependencies in your package.json
npmDnpm i -DInstall and save to dev-dependencies in your package.json
npmFnpm i -fForce install from remote registries ignoring local cache
npmEPATH="$(npm bin)":"$PATH"Run command from node_modules folder based on current directory
npmOnpm outdatedCheck which npm modules are outdated
npmUnpm updateUpdate all the packages listed to the latest version
npmVnpm -vCheck package versions
npmLnpm listList installed packages
npmL0npm ls --depth=0List top-level installed packages
npmstnpm startRun npm start
npmtnpm testRun npm test
npmRnpm runRun npm scripts
npmPnpm publishRun npm publish
npmInpm initRun npm init
npminpm infoRun npm info
npmSenpm searchRun npm search
npmrdnpm run devRun npm run dev
npmrbnpm run buildRun npm run build

npm install / npm uninstall toggle

The plugin adds a function that toggles between npm install and npm uninstall in the current command or the last command, for up to 2 previous commands. The default key binding is pressing <kbd>F2</kbd> twice.

You can change this key binding by adding the following line to your zshrc file:

zsh
bindkey -M emacs '<seq>' npm_toggle_install_uninstall
bindkey -M vicmd '<seq>' npm_toggle_install_uninstall
bindkey -M viins '<seq>' npm_toggle_install_uninstall

where <seq> is a key sequence obtained by running cat and pressing the keyboard sequence you want.