Installation
Binhjs = binhjs + binhend
binhjsis a library running front-end code on browser.binhendis 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.
Use the Fast Track to understand Binhjs by playing!
Requirements
- Node.js version 18.0 or above.
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.jsonis a JSON file generated by NPM after initializing project, holding information and settings of project.package-lock.jsonis 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 packagebinhend, holding dependencies.frontend/is a folder generated bybinhendafter 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.
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