What if you could interact with and run node modules without having them downloaded locally? What if you could directly run the code of your GitHub gist? Doesn’t sound possible? It actually is. In this article, we’ll talk about **npx (**package runner) — what it is, why we need it, and the use cases where the tool is helpful when running node packages from the command line. Background (node package manager) has improved a lot over the years and provides a way for to have a global and local installation of packages. There are times you are required to look over a package and try out commands, or you might even want to get rid of . From , npm started installing a new binary alongside the usual npm called npm developers devDependencies npm@5.2.0 npx. _npx_ : An npm package runner — helps to execute packages without installing explicitly. $ which npx If for some reason it’s not available, install or update it as the following: $ npm install -g npx makes it easy to install and manage dependencies hosted in npm registry. It simplifies the process and provides a better for executables. npx $ npx <command> //command: package to be installed Use cases: To execute one-off commands To use based scripts gist To use different versions of an npm module If you don’t have permission to install it globally. Execute one-off commands: Uses create-react-app execution to create a new app without installing in global There are times you wanted to try some CLI tools but it’s annoying to have it installed globally (or) locally just to run it once. is a great way for solving this. Using to initiate the execution of a package. If is not already in your will install the package from npm registry and invoke it. will not maintain the packages in the globals, So you don't have to worry about polluting your globals. npx npx <command> <command> $PATH, npx npx Tools like only called once in a while. If you have these installed in your globals, You might have those outdated by the time when you use. You might end up having to run install every time you wanted to use. is a good way to solve this problem. create-react-app npx Execute gist based scripts: gist execution You can use to share any utility scripts instead of creating a git repository. can consider executing any specifier that npm does. You can invoke a gist directly using npx. gist.github.com npx Make sure to read through the gists when executing as they could cause serious problems if the script is having some malicious process. SHELL auto fallback: You can configure npx to run as your default fallback command when you type something in the command line with an and the command is not found. This includes installing packages that were not found in the local prefix either. @ Mac OS X by default runs with bash version <4. As OS X did not update to latest version of bash which is licensed under GPLV3. Here is the reason why is an alternative for bash which can be used with OS X. Here are the differences for both. Installing and making as your default shell Zsh bash vs Zsh & zsh Restart the shell after the installation. As it’s the first time after the shell update., will ask for a few initial settings. Now, You can set up auto fallback. zsh To allow the current shell session to have the fallback $ source <(npx --shell-auto-fallback <shell>) To install permanently, add ` to your , , as needed npx --shell-aut-fallback <shell> ~/.bashrc ~/.zshrc ~/.config/fish/config.fish : can be <shell> zsh, bash (≥4) (or) fish $ mocha@4.1.0 --versionmocha@4.1.0 is not found. Trying with npx ...npx: installed 24 in 2.243s4.1.0 Now, You can try to install any package like which will try to find the webpack in project level if not it will automatically fallback to use $ npm run mocha@3.2 npx. There is a course for in egghead.io (if you are interested) npx Conclusion helps to solve the problems of installing unnecessary packages just to look through. It’s an easy way to avoid versioning problems and dependency issues. Like I always say, Will be back with more interesting topics. Cheers! npx **code** = **co**ffee + **de**veloper