Today I Learned

hashrocket A Hashrocket project

Execute NPM binary without installing package

When working with command-line tools, it's common to encounter scenarios where you'd like to test or run a tool without committing to a global installation, especially for one-off tasks. The npx utility addresses this exact need. By invoking npx <command>, the tool automatically fetches and installs the package corresponding to <command> from the npm registry if it's not already in your $PATH. This allows you to execute the desired command seamlessly. A significant advantage is that post-execution, npx ensures the package is not retained as a global installation, preventing unnecessary clutter or "pollution" in your global packages. This utility offers a cleaner, transient approach to testing and using CLI tools.

See More #javascript TILs
Looking for help? At Hashrocket, our JavaScript experts launch scalable, performant apps on the Web, Android and iOS. Contact us and find out how we can help you.