Skip to content

vivaxy/NiB

Repository files navigation

NiB

Run Node.js modules in browser environment.

NPM Version NPM Downloads MIT License Standard Version

Install

yarn add @vivaxy/nib or npm i @vivaxy/nib

Usage

<html>
<body>
<script src="https://unpkg.com/@vivaxy/nib/index.js"></script>
<script>
window.node.init({ base: '.', nodeBuiltInBase: 'https://unpkg.com/@vivaxy/nib', nodeModulesBase: 'https://unpkg.com' });
window.node.require('./index.js');
</script>
</body>
</html>

Options

  • base: path from html to your commonjs module
  • nodeBuiltInBase: path from html to @vivaxy/nib
  • nodeModulesBase: path from html to node_modules

In your ./index.js you can now use require and module.exports!

See test and test source.