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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cross-cmd

v2.0.0

Published

Cross-platform CLI commands

Downloads

8

Readme

cross-cmd ✨

Cross-platform CLI commands

The problem

I was trying to create a CLI package using my linux system, and I wanted to trigger a command that reads a file. Being linux, I used cat and it worked perfectly. But, for people using my package on a different operating system like windows, they'd never be able to trigger a command like cat.

This Solution

This CLI package has many commands with different purposes mapped to different operating system commands. You give it a command and the required options, and it runs the appropriate command for the platform is used with the options provided.

Usage

This library comes in handy when creating a CLI package and you want to target various platforms.

Note that this is a javascript library.

Installation

npm i cross-cmd

In your project

Let's say you use spawnSync from the child_process module in NodeJS (it could be any function, as long as it executes terminal commands) and you're developing your package on a linux system:

const {spawnSync} = require('child_process');
spawnSync('node', ['./node_modules/cross-cmd', 'cat', 'path-to-file'], {
    stdio: "inherit"
})

What happens here is that cross-cmd checks its list of commands, gets the one with cat and appropriately apply the command for the platform it is being run on. For example, your package with this command executed on linux and windows respectively would be:

# linux
cat path-to-file
# windows
type path-to-file

This is because 'type' is a win32 representative associated with linux's 'cat' as saved in the list of commands.

cross-cmd is not installed globally, that's why it is accessed with node ./node_modules... instead of cross-cmd.... Just as I wouldn't want the users of this package to have it installed globally against their will, the users wouldn't also want the users of their packages to do the same.

If the command does not exist, it throws an error. When this happens, you can do me and the community a favor by creating a feature request issue of the command you want to be added.

For commands with spaces

e.g type nul > which creates an empty file in windows as touch does in linux and is saved in the command list, a windows user of this package would have to do the following:

const {spawnSync} = require('child_process');
spawnSync('node', ['./node_modules/cross-cmd', 'type nul >', 'path-to-file'], {
    stdio: "inherit"
})

cross-cmd changes the command 'type nul >' depending on the os.

All commands

It is important to confirm that a command exists before using it in your package. You can run the following to confirm that a command exists:

node ./node_modules cross_cmd <command-name> --help

Or find all commands available here.

Issues and Contributions

Your contribution to this project would be highly appreciated. Could be a documentation issue, pull request, feature request, they are all welcome.

LICENSE

MIT