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 welcomejs with all npm packages installed. Try it out:

var welcomejs = require("welcomejs")

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

welcomejs v0.0.2

A welcome library where the modules will welcome you (ie the output of a getting started tutorial)

Welcome Library


The welcome Library is a minimal (getting started) javascript library that will welcome you from two modules.

The story (or blog) over this repository can be found here:

This repository will build a library:

  • exposed as the global variable welcome
  • saved in the file prefix-welcome.js
  • aggregating two modules (foo and bar)
  • testing a method

The tool used are:

  • Node for the module dependency
  • WebPack as builder.
  • Jest as test runner


The output from the browser or from Node will be

Welcome from the foo package !
A warm Welcome from the bar package !

Usage of the Git Repository

git clone
  • Execute a npm install
  • Execute a npm run test to execute the test with Jest through npm
npm run test

Jest output

  • Execute a npm run build to build the library prefix-welcome.js in the directory dist
npm run build

Webpack output

  • Run the examples given in the usage section below.

Usage of the final library with examples


See the file welcomeLibInNode.js

var welcome = require("../dist/prefix-welcome");
  • Run it
C:\welcome\example>node welcomeLibInNode.js
  • Output:
Welcome from the foo package !
A warm Welcome from the bar package !


See the file welcomeLibInBrowser.html

If published in Node
<script src=""></script>
Otherwised locally
<script src="../dist/prefix-welcome.js"></script>
    // Global variable
    var welcomeFoo =;
    // Property in the window object
    var welcomeBar =;
    document.body.innerHTML = "<h2>"+welcomeFoo+"</h2><h2>"+welcomeBar+"</h2>";
  • Run it:

Browser output example

Note on dependency

Note on thenpm configuration file package.json:

  • Babel has been added to be able to use the import statement with the jest test framework. jest is a node process and actually understand only require
  • Webpack 2 understands natively the import statement.


  • package-lock.json should be versionned. npm create it. It's a lockfile that is automatically generated for any operations where npm modifies either the node_modules tree, or package.json. It describes the exact tree that was generated, such that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates.
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