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

npmflat

v0.1.7

Published

Flattens the npm hierarchy into an npm-shrinkwrap.json file, especially useful for Windows systems

Downloads

3

Readme

npmflat

Analyze a package.json and produce the npm-shrinkwrap.json file that may be used by npm or directly by npmflat to install dependencies into a flattened structure given each packages semantically versioned dependencies. npmflat differs from other node_module hierarchy flattening modules that I’ve come across in that it does not install a deep nest and then move things around - it builds the npm-shrinkwrap specifically to reduce installation and install depth overhead from the start.

As a side-effect, npmflat also deduplicates modules to some degree although a better algorithm for selecting packages that move up the dependency graph could be developed in order to further optimize. At this point however the first package encountered while searching the hierarchy tree of package.json’s is moved to the top of the hierarchy and if other semantically versioned dependencies in the graph would be in conflict, then they are promoted up the hierarchy until a potential conflict would occur.

npmflat may be handy on windows systems where common utilities such as Explorer and DOS have character limits of something like 260 characters for file name and path together (yes this is the case, and yes the year is currently 2015).

Install: npm install -g npmflat

Usage: npmflat [--production] [install]

Examples:

  • npmflat will produce the npm-shrinkwrap.json file in the directory from which it is executed including the dependencies, devDependencies, and optionalDependencies indicated in the package.json that should also be present in the current working directory. It will not execute an npm install, that would have to be done manually (npm install).
  • npmflat --production will produce an npm-shrinkwrap.json provided a package.json in the same directory exists including dependencies and optionalDependencies but excluding devDependencies.
  • npmflat install does the same thing as npmflat but also executes npm install programmatically.
  • npmflat --production install does the same thing as npmflat --production but also executes npm install programmatically.

Notes

  • npmflat will overwrite any existing npm-shrinkwrap.json file present!

  • npmflat itself only requires npm to be globally installed prior to execution.

  • npmflat does not yet pass command-line arguments to npm when the install option is provided. So for example, on windows if you wanted to pass the Visual Studio 2013 tool-chain to node-gyp via the npm install switch -msvs-version=”2013” then you would prefer to use npmflat to generate the npm-shrinkwrap.json and execute npm install -msvs-version=”2013” separately.

  • If you get ENOENT error on install it may be the case that one of your locally installed modules is attempting to chmod a bin file that does not exist due to our modified npm-shrinkwrap.json file (it exists somewhere else up the hierarchy now). If this is happening to you, try running npm install --no-bin-links and then find the offending file elsewhere in the hierarchy and chmod +x manually (if this is necessary for the package to work for you, which it may not be)

  • Sometimes I’ve wound up with large npm-shrinkwrap.json files that npm install hangs on. If you experience this issue, try splitting the npm-shrinkwrap.json top-level dependencies into two or more non-overlapping shrinkwrap json files and doing the install for each individually (by renaming the original and in-turn renaming the split shrinkwrap files in-turn to npm-shrinkwrap.json and executing npm install for each). I’ve only had this happen when I’m at around 6000+ line npm-shrinkwrap.json and splitting it into two worked.