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

nah

v0.0.3

Published

Nah is a simple Node.js version manager.

Downloads

1

Readme

Nah

Nah is a simple Node.js version manager. It installs them and switches between them. That's about it.

I've been a long time user of nvm and have been pretty happy with. One thing that has always bugged me however is the noticeable slowdown it imposes on opening new terminals or just tabs. After realizing that I don't really use 95% of its features and might as well get around just by manually symlinking the current Node.js version, I wanted something to automate the process. And here we are.

Installation

Nah is distributed as an NPM package which means it needs an existing Node.js runtime to bootstrap. Install one using your operating system's package manager or similar.

$ npm install -g nah

Nah stores the currently selected Node.js version symlinked into a special directory called current. Add it to your $PATH.

export PATH="$HOME/.nah/current/bin:$PATH"

Usage

Nah has a concept of channels which correspond to the channels as used by Node.js. For example, there's a release channel for the official builds intended for end-users or nightly which contains snapshots of the current master branch. There's also rc or chakracore-nightly. Have a look here for the complete list. Nah should be able to install from any of them as long as the structure of the files is the same.

Anyway, use the channel to specify the Node.js channel if necessary. It defaults to release when omitted.

$ nah install release/8.1.0
$ nah install 8.1.0
$ nah install 8.1

Notice how the version expands. Each missing part of the specified semver is automatically replaced with a zero. This makes 8 and 8.0.0 equivalent.

It's also possible to ask for the current latest version.

$ nah install nightly/latest
$ node -v
nightly/v9.0.0-nightly20170608d0571a926a

To switch versions, use the current command. Without an argument it just prints the current version and its location.

$ nah current
• The current version is set to "release/v8.1.0" and located at "/Users/jiripospisil/.nah/versions/release--v8.1.0".

$ nah current 7.9
$ nah current
• The current version is set to "release/v7.9.0" and located at "/Users/jiripospisil/.nah/versions/release--v7.9.0".

For all of the available commands, run nah --help.

How it works

Nah stores installed Node.js versions in a directory called versions. When setting a "current" version, it just creates a symlink to the versions directory.

tree -L 2 ~/.nah
.nah
├── current -> /Users/jiripospisil/.nah/versions/release--v8.1.0
├── hooks
│   └── post_install.sh
└── versions
    ├── chakracore-nightly--v9.0.0-nightly20170611cb859bc137
    ├── nightly--v9.0.0-nightly20170608d0571a926a
    ├── nightly--v9.0.0-nightly2017061227cc30aea8
    ├── release--v7.9.0
    ├── release--v8.0.0
    └── release--v8.1.0

This means that once the current version is changed, it's changed immediately everywhere, in every opened shell. Since Nah is distributed as an NPM package, it's not be available right after installing of a new Node.js version. To solve this, Nah has a concept of hooks which allow to execute arbitrary shell scripts each time a new version is installed.

$ cat ~/.nah/hooks/post_install.sh
#!/bin/sh

npm install -g nah

This ensures that Nah is always available. Feel free to add any other packages.

License

ISC