GithubHelp home page GithubHelp logo

stefanretief / nodebowl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sfranzyshen/nodebowl-1

0.0 1.0 0.0 0 B

A in-browser lib that emulates the Node.js API includes fs, require, etc.

JavaScript 100.00%

nodebowl's Introduction

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 nodebowl from 'nodebowl';

const { fs, run } = window.nodebowl;

API

run(file[, args][, options])

  • 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

  • simple examples/simple
  • webpack examples/webpack

Dev

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

Contributors

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

nodebowl's People

Contributors

jiacheng9 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.