What is Node.js?
At its most basic level, Node.js is an open-source, cross-platform runtime environment that allows you to run JavaScript code outside of a web browser.
Traditionally, JavaScript was only used inside web browsers to make websites interactive (the frontend). Node.js changed everything by taking the ultra-fast V8 JavaScript engine—originally built by Google for the Chrome browser—and allowing it to run natively on servers or local computer operating systems (the backend).
Why Do Developers Use It?
- A Single Language: Developers can use JavaScript to write both their website's user interface and the underlying server logic, meaning they don't have to switch between different programming languages.
- High Performance: Because it is powered by Google's V8 engine, Node.js executes code incredibly fast by compiling JavaScript directly into native machine code.
- Asynchronous Processing: It is designed to handle multiple tasks at once. It can process thousands of file reads or database requests simultaneously without getting "stuck" waiting for a single task to finish.
- Massive Library Ecosystem: It includes npm (Node Package Manager), which is the largest registry of open-source software libraries in the world. This allows developers to easily download pre-written tools instead of building everything from scratch.
how to setup node.js step by step
Step 1: Download the Node.js Installer
- Open your web browser and go to the official website: https://nodejs.org/
- Download the LTS (Long Term Support) version. This is the most stable release recommended for most users.
- Once the installer file (
.msifor Windows or.pkgfor macOS) finishes downloading, open it.
Step 2: Run the Installation Wizard
- Click Next to accept the license agreement.
- Keep all the default settings selected (do not uncheck any boxes).
- Important for Windows users: If a screen asks to install "Tools for Native Modules," leave it unchecked (you do not need extra C++ compilation tools for this project).
- Click Install, authorize administrative access if prompted, and click Finish.
Step 3: Verify the Installation
-
Open your terminal:
- Windows: Press the
Win Key + R, typecmd, and hit Enter to open the Command Prompt. - Mac: Press
Cmd + Space, typeTerminal, and hit Enter.
- Windows: Press the
-
Run the following command to check the Node version:
(You should see a version number output likenode -vv20.x.xor higher). -
Run the following command to check
npm(Node Package Manager, installed automatically alongside Node):npm -v
Step 4: Initialize Your Converter Project Folder
- Create a dedicated folder on your computer for your conversion project (e.g.,
stroke-converter). -
Navigate into that folder using your terminal:
cd path/to/your/stroke-converter -
Initialize a Node.js project inside the folder by running:
(This instantly generates anpm init -ypackage.jsonfile that keeps track of your installed tools).
Step 5: Install Required Conversion Libraries
Run this single command in your terminal while inside your project folder to install the parsing tools:
npm install cheerio svg-path-properties
Once installed, your environment is fully configured. You can now create a .js file inside that folder to run your SVG conversion scripts.
convert.js
1. convert.js
Create a file named convert.js in your project folder
2. How to Run the Script
- Place your animCJK SVG files into a folder named
svgsZhHantinside your project directory. -
Open your terminal in the project directory and run:
node convert.js
To convert Hong Kong files later, change INPUT_DIR = './svgsZhHk' and SUFFIX = 'hk' at the top of convert.js and run the script again.
