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

jsrun-cli

v0.1.1

Published

A lightweight CLI tool for running JavaScript, TypeScript, and .jsr scripts with automatic dependency management.

Downloads

11

Readme

JSRUN

The ultimate CLI tool for effortlessly running JavaScript, TypeScript, and .jsr scripts.

⚡ Focus on coding, let JSRUN handle the rest! ⚡

npm version License: MIT npm downloads


✨ Features

  • Automatic Module Management: Automatically installs missing dependencies.
  • Version Control: Specify version numbers directly in your imports.
  • Caching for Speed: Locally cached modules reduce installation time.
  • Colorful Logging: Clear, colorful logs powered by chalk.
  • Error Handling: Comprehensive error messages for easy troubleshooting.
  • Extendable: Customizable and ready for expansion.

🔧 Installation

Prerequisites

Install via npm

npm install -g jsrun-cli

🚀 Usage

Run a Script

Run any script supported by JSRUN:

jsrun myscript.jsr

Supported extensions: .jsr, .js, .mjs, .ts.

Import Modules with Versions

import express from "[email protected]";
import chalk from "[email protected]";

console.log(chalk.green("Starting server..."));
const app = express();
app.get("/", (req, res) => res.send("Hello World!"));
app.listen(3000, () => console.log(chalk.blue("Server running on port 3000")));

Run the script:

jsrun server.jsr

Pass Arguments to Your Script

jsrun myscript.jsr --port=4000 --env=production

Inside your script:

const args = process.argv.slice(2);
const port =
    args.find((arg) => arg.startsWith("--port="))?.split("=")[1] || 3000;
const env =
    args.find((arg) => arg.startsWith("--env="))?.split("=")[1] || "development";

console.log(`Running on port ${port} in ${env} mode.`);

🧹 Clean Installed Packages

jsrun --clean

🎯 Key Features Explained

  • Performance Caching: Caches modules locally in ~/.jsrun/node_modules to speed up subsequent runs.
  • Colorful Logging: Uses chalk for colored feedback (Green for success, Yellow for warnings, Red for errors, and Blue for status).
  • Error Handling: Gives detailed error messages, simplifying debugging and fixing issues.

📝 Why JSRUN?

JSRUN was created to make running JavaScript and TypeScript scripts with modules a breeze, without the hassle of managing node_modules. Instead of manually installing packages every time, JSRUN handles everything for you. It installs the necessary dependencies automatically, allowing you to create and run executable scripts from anywhere with minimal setup.

No more worrying about how to manage node_modules just focus on writing and running your scripts, and let JSRUN take care of the rest!


📂 Examples

Explore the /examples directory for use cases and .jsr script examples.

🛠️ Troubleshooting

Common Issues

  1. Module Not Found: Ensure module names and versions are correct.
  2. Permission Denied: Use elevated privileges or adjust the ownership of the ~/.jsrun folder.
  3. Syntax Errors: Verify that your JavaScript/TypeScript syntax is correct. Use the appropriate Node.js version.
  4. Network Problems: Check your network connection or try manually installing the module.

❓ FAQ

  1. Why .jsr?
    .jsr highlights scripts specifically made for jsrun.

  2. Can I use .js files?
    Yes, .js files are supported, but .jsr is recommended for clarity.

  3. Where are modules installed?
    In the cache directory ~/.jsrun/node_modules.

  4. How do I update jsrun?
    Run npm update -g jsrun-cli.


🤝 Contributing

  1. Fork the repo
  2. Create a new branch
  3. Make your changes
  4. Push your branch
  5. Submit a Pull Request

📜 License

jsrun is licensed under the MIT License.


✉️ Contact

Have questions or feedback? Check out our GitHub page.


📚 Documentation en Français

Pour la documentation en français, consultez ce lien.