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

cnsh

v4.1.0

Published

A lightweight package manager

Downloads

11

Readme

cnsh

npm version npm downloads License Coverage Status GitHub stars GitHub forks

cnsh is a lightweight package manager that provides a minimal alternative to Yarn. It fetches packages from the npm registry and installs them in a simplified directory structure.

Features

  • Add Packages: Install packages from the npm registry.
  • Remove Packages: Uninstall packages from your project.
  • Install Dependencies: Install all dependencies listed in package.json.
  • Global and Local Installation: Supports both global and local package management.
  • Simple and Efficient: Focuses on essential features for ease of use.

Installation

To install cnsh globally, follow these steps:

  1. Install via npm

    Run the following command in your terminal:

    npm install -g cnsh --verbose

    This will install cnsh globally, making it available from any directory on your system.

  2. Verify Installation

    To check if cnsh is installed correctly, run:

    cnsh <random-letters-and-numbers>

    For example:

    cnsh asdf1234

    If cnsh is installed, you should see the following output in red text:

    Unknown command. Use "add", "remove", or "install".

    This confirms that cnsh is properly installed and recognizing commands.

Usage

cnsh offers a simple set of commands for managing packages. Here’s how to use it:

Adding a Package

To add a package to your project, use:

cnsh add <package-name> --verbose
the verbose flag is optional, it is used to display more information

For example, to add lodash:

cnsh add lodash --verbose

This installs lodash into your project's cnsh_lib directory.

Updating

To update it, run this command in your terminal:

npm install -g cnsh@latest

Removing a Package

To remove a package, use:

cnsh remove <package-name>

For example, to remove lodash:

cnsh remove lodash

Installing Dependencies

To install all dependencies listed in your package.json, use:

cnsh install

This reads the package.json file and installs all listed dependencies into your cnsh_lib directory.

Global Installation

To install a package globally, use:

cnsh add -g <package-name>

Global packages will be installed in a global directory (typically ~/.cnsh-global/cnsh_lib).

Help

For a list of available commands and help, use:

cnsh --help

Note: Running unavailable commands will display the available commands. Since the help command itself is unavailable, it's kind of a win-win situation!

Example: Using axios with cnsh

Here’s a demonstration of how to use axios with cnsh:

  1. Install axios

    cnsh add axios
  2. Create a Simple Node.js Script

    Create a file named app.js with the following content:

    // Import axios from the local path where cnsh stores it
    import axios from './cnsh_lib/axios/package/dist/esm/axios.min.js';
    
    // Function to fetch data from a public API
    async function fetchData() {
        try {
            const response = await axios.get('https://jsonplaceholder.typicode.com/posts/1');
            console.log('Data fetched:', response.data);
        } catch (error) {
            console.error('Error fetching data:', error);
        }
    }
    
    // Call the fetchData function
    fetchData();

or if you like CommonJS better:

async function fetchData() {
    try {
        const axios = await import('./cnsh_lib/axios/package/dist/esm/axios.min.js');
        const response = await axios.default.get('https://jsonplaceholder.typicode.com/posts/1');
        console.log('Data fetched:', response.data);
    } catch (error) {
        console.error('Error fetching data:', error);
    }
}

fetchData();

UMD:

(function (root, factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD
        define(['axios'], factory);
    } else if (typeof module === 'object' && module.exports) {
        // Node.js or CommonJS
        module.exports = factory(require('./cnsh_lib/axios/package/dist/axios.js'));
    } else {
        // Browser global
        root.fetchData = factory(root.axios);
    }
}(typeof self !== 'undefined' ? self : this, function (axios) {
    'use strict';

    // Function to fetch data from a public API
    async function fetchData() {
        try {
            const response = await axios.get('https://jsonplaceholder.typicode.com/posts/1');
            console.log('Data fetched:', response.data);
        } catch (error) {
            console.error('Error fetching data:', error);
        }
    }

    // Return the function as part of the UMD module
    return fetchData;
}));

// To call fetchData in a browser environment:
fetchData();
  1. Run Your Script

    Execute your script using Node.js:

    node app.js

    You should see the data fetched from the public API printed to your console.

Contributing

Feel free to open issues or submit pull requests to help improve cnsh. If you have suggestions or feature requests, please let us know!

License

This project is licensed under the ISC License - see the LICENSE file for details.