0.8.1 • Published 2 years ago

nodebowl v0.8.1

Weekly downloads
67
License
-
Repository
github
Last release
2 years ago

nodebowl

nodebowl

Put node in a bowl.

nodebowl is a in-browser lib that emulates the Node.js API includes fs, require, etc. It can run many Node.js lib in browser,eg: webpack in browser.


This project just started,please consider starring the project to show your ❤️ and support if you like it.

Getting Started

$ npm install nodebowl
<script src="node_modules/nodebowl/dist/nodebowl.js"></script>
<script>
  const { fs, run } = window.nodebowl;
  fs.writeFileSync('/foo.js', `
    module.exports = 1;
  `);
  fs.writeFileSync('/index.js', `
    const num = require('./foo');
    console.log(num);
  `);
  run('/index.js');
</script>

or import it

import * as nodebowl from 'nodebowl';

const { fs, run } = nodebowl;

API

run(file, args)

  • file \<string> The name or path of the executable file to run.

  • args \<string[]> List of string arguments.

  • options \<object>

    • cwd \<string> Current working directory.Default: /
    • env \<object> Environment key-value pairs.
run('index.js'); // node index.js

run('index.js', {
  env: {
    NODE_ENV: 'dev'
  }
}); // NODE_ENV=dev node ./index.js

run('./dir/index.js', ['--v']); // node ./dir/index.js --v

helpers.installFromZip(url)

  • url \<string> The zip url.

When you need to download the zip file like node_modules, you can use this helper method.

Other API

Other API emulates Node.js API, includes: fs, path, etc...

Alternatively, you can use the require method just as you are using Node.js.

Examples

Dev

$ yarn
$ yarn dev
$ open http://localhost:8080/examples/simple/index.html

Contributors

Welcom issue and pr, more details will be explained later.

0.8.1

2 years ago

0.8.0

2 years ago

0.7.0

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.2

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago

0.0.0

5 years ago