npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nartallax/npm-run

v1.0.3

Published

A small command-line tool to substitute `npm run` with.

Downloads

293

Readme

@nartallax/npm-run

A small command-line tool to substitute npm run with.

Install

npm install -g @nartallax/npm-run

Use

nr my-command-from-packagejson

Optimization(s)

If command starts with node something.mjs, or just ./something.mjs - the mjs file will be imported within process of npm-run (with argv and cwd updated to match what file would expect). This avoids to spin up new NodeJS instance.
This optimization is applied on very specific conditions - all arguments must be alphanumeric (otherwise we are at risk of misinterpreting some smart-er shell syntax as arguments, which will lead to unexpected results).
Also there must be exactly one space between node and path start (or no spaces in the case of shebanged script call). This allows to override this optimization by adding more spaces, which should not affect logic of the script.

Every command not matching above conditions will just be run in system's default shell.

Why?

I like to keep every single action I may want to run about my project in package.json scripts. Literally everything - build actions, diagnostics, systemd management...
This requires me to run npm run commandname every time I want to run a command. It's convenient to have everything in one place, but comes with some problems:

  • npm run sometimes takes noticeably more time than just running the command in the shell (sometimes up to 400ms more time). It's not much, but in case of short-lived commands like "show me systemd status of my service" it is very noticeable. (and yes, yarn also has this problem, sometimes even worse).
  • npm run is a bit too much characters to type for my taste.

So here comes this package, adding nr command, that does exactly the same as npm run, just slightly better.