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

@celkamada/npm-git-install

v0.1.7

Published

Clones and (re)installs packages from remote git repos

Downloads

4

Readme

NPM Git Install

Clones and (re)installs packages from remote git repos. It is meant as a temporary solution until npm/npm#3055 is resolved.

Install

npm install --save npm-git-install

Use

In your pacakge.json add:

{
  "scripts": {
    "install": "npm-git-install"
  }
  "gitDependencies": {
    "private-package-name": "[email protected]:user/repo.git#revision",
    "public-package-name": "https://github.com/user/repo.git#revision"
  }
}

Obviously replace *-package-name and git URLs with values relevant to your project. URLs has to be in cannonical form (i.e. one that you would provide to git clone on command line) - no fancy NPM shortcuts like "user/repo" or "bitbucket:user/repo". If you want this, I'm open for PR. Actually I started to implement this, but gave up - see messy-auto-discovery branch.

Why

IMO there is a serious defect in current versions of NPM regarding installation process of dependencies from git repositories. It basically prevents us from installing anything that needs build from git repos, or forcing us to keep build artifacts in the repos. Here is relevant issue with ongoing discussion.

TL/DR:

If you npm install ../some-local-directory/my-package then npm will run prepublish script of the package-from-local-directory and then install it in current project. This is fine.

One would expect that running npm install git@remote-git-server:me/my-package.git would also run prepublish before installing. Unfortunately it won't. Further more, it will apply .npmignore, which will most likely remove all your source files and make it hard to recover. Boo...

How

From command line

npm-git-install

This simple script will git clone anything it finds in gitDependencies section of package.json into temporary directory, run npm install in this directory (which will trigger prepublish) and then npm install <temporary directory> in your project. In effect you will get your dependency properly installed.

You can optionally specify file different then package.json, e.g.:

npm-git-install git-dependencies.json

You may want to do this if you find it offensive to put non-standard section in your package.json.

Also try --help for more options.

API

You can also use it programmatically. Just require npm-git-install. It exposes three methods:

  • discover (path)

    Reads list of packages from file at given path and returns array of {url, revision} objects. You can supply this to reinstall_all method.

  • reinstall_all (options, packages)

    Executes reinstall in series for each package in packages. Options are also passed to each reinstall call.

    Returns a Promise.

  • reinstall (oprions, package)

    Clones the repo at package.url, checks out package.revisios, runs npm install at cloned repos directory and installs the package from there.

    Options are:

    • silent: Suppress child processes standard output. Boolean. Default is false.
    • verbose: Print debug messages. Boolean. Default is false.

    Returns a Promise.

    You probably don't want to use it directly. Just call reinstall_all with relevant options.

If you are a Gulp user, then it should be easy enough to integrate it with your gulpfile.

Why not use dependencies and devDependencies

I tried and it's hard, because NPM supports fancy things as Git URLs. See messy-auto-discovery branch. You are welcome to take it from where I left. There is --all CLI option reserved that should do that. It is currently not supported.

There is also another reason. User may not want to reinstall all Git dependencies this way. For example I use gulp version 4, which is only available from GitHub and it is perfectly fine to install it with standard NPM. I don't want to rebuild it on my machine every time I install it. Now I can leave it in devDependencies and only use npm-git-install for stuff that needs it.