Skip to main content

Installation

Binhjs = binhjs + binhend

  • binhjs is a library running front-end code on browser.
  • binhend is a package of NodeJS providing tools to build web app project.

In this tutorial, binhend is used to set up a new front-end project, meanwhile, binhjs is included to webpage on launched.

tip

Use the Fast Track to understand Binhjs by playing!

Requirements

Create a new project

Use NPM to initialize a project by default:

npm init

After going through prompts, NPM will create a file package.json.

Next, install package binhend:

npm install binhend

Then, use binhend to create a folder structure for frontend.

npx binhend create frontend

By default, this command will create a folder named frontend.

If you want to create a folder with another name, for example my-app, use:

npx binhend create frontend my-app

Or using the current working folder: (directory path where the command is executed)

npx binhend create frontend ./

So far, your project structure will look like this:

project
├── node_modules/
├── frontend/
├── package-lock.json
└── package.json
  • package.json is a JSON file generated by NPM after initializing project, holding information and settings of project.
  • package-lock.json is auto-generated by NPM, showing the entire dependency tree of a project, should not be touched.
  • node_modules/ is a folder generated by NPM after installing package binhend, holding dependencies.
  • frontend/ is a folder generated by binhend after using command to create a folder with sample frontend structure.

Start web app

Run the development server:

npx binhend start frontend

Or use native command:

node frontend/server.js

The command builds your project locally and serves it through a development server.

Open http://localhost:1234 to view your website.

tip

In case you create a new project with another name, for example my-app, change above commands to:

npx binhend start my-app
node my-app/server.js