Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including ngn-util with all npm packages installed. Try it out:

var ngnUtil = require("ngn-util")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

ngn-util v0.0.1

ngn-util ========


NGN System Utilities

Installation: npm install ngn-util.

Auto-install missing module.

The following code will automatically and synchronously install a module if it is not already installed. Supports global installs, which automatically links the global module to the current working directory. Supports alternative npm registry.

var util = require('ngn-util');
var uuid = util.require('node-uuid');




The system utilites also provide some wrappers around npm. This includes:

  • npm.install()
  • npm.installSync()
  • npm.installed()
  • npm.globalDirectory
  • npm.globalLink()
var util = require('ngn-util');

var config = {
  package: 'myModule',
  name: 'My Awesome Module', // <-- Descriptive name for module (used in CLI status)
  global: false,
  registry: ''

// Install a module asynchronously

// Install a module synchronously

console.log(util.npm.globalDirectory); // Show the path to npm global


To check if a module is already installed:

var util = require('ngn-util');


Returns an object like:

  global: false,
  local: true

The method can be passed an optional second argument of which directory should contain the module if installed locally.

Example: util.npm.installed('myModule','/path/to/my/project');

Wrapped Modules

tl;dr:This module auto-installs what NGN needs.

The NGN Utility library will manage certain module dependencies dynamically. For example, if var util = require('ngn-util'); util.execSync(...); is called, the utility will attempt to install the exec-sync module. If it is not found, it will be installed globally and a link will be created. This allows reuse of common modules throughout the NGN platform without adding redundant installations of the same modules (as is common many node modules). Of course, individual modules can be overridden as necessary.

The following modules are wrapped into the NGN utilities:

  • exec-sync (Execute commands synchronously... CLI-ONLY!)
  • bcrypt (strong encryption)
  • seq (flow control)
  • read (CLI prompt)
  • colors (colorized console output)
  • optimist (CLI argument utility)


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free