Help Center> Optical Character Recognition> SDK Reference> SDK Environment Setup> Preparing a Node.js Development Environment

Preparing a Node.js Development Environment

Scenario

OCR Node.js SDK supports Windows, Linux, and Mac operating systems. This section uses Windows as an example to describe how to configure the environment. Table 1 describes the required operating environment.

Table 1 Environment preparation

Item

Description

OS

Windows OS. Windows 7 or later is recommended.

Installing Node.js

Node.js v10.13.0 or later is recommended.

Installing Node.js library dependency

OCR Node.js SDK depends on the third-party request, moment, and moment-timezone library packages.

Procedure

The following describes how to install and configure Node.js v10.13.0 in the Windows 7 environment. If you have installed Node.js v10.13.0 or later and the required library packages, skip this section.

  1. Configure Node.js.

    Go to https://nodejs.org/en/download/ to download the latest Node.js.

    Right-click Computer, choose Properties > Advanced System Settings > Environment Variables, and add C:\Program Files\nodejs (default installation path of node.exe) to Path.

  2. Verify Node.js.

    Run the node –v command in the system CLI to check the Node.js version. If the current version number is displayed, the configuration is successful.

  3. Run the following command to configure cnpm and the software library.
    $ npm install -g cnpm --registry=https://registry.npm.taobao.org

    If you have configured them, go to 4.

  4. Install a dependency package.

    Go to the root directory of Node.js. Press and hold down Shift, right-click in the window, and choose Open command window here from the shortcut menu. Then, run the following commands:

    cnpm install request –save
    cnpm install moment --save
    cnpm install moment-timezone --save