• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Usage of Third- and Fourth-Party Libraries
2
3## How do I obtain available third-party libraries?
4
5Applicable to: OpenHarmony 3.1 Beta5 (API version 9)
6
7The three-party and four-party libraries that can be obtained through ohpm are summarized in the [OpenHarmony-TPC/tpc_resource repository](https://gitee.com/openharmony-tpc/tpc_resource). You can access this repository, and find the desired component based on the directory index.
8
9## Which third-party libraries are related to network requests?
10
11Applicable to: OpenHarmony 3.1 Beta5 (API version 9)
12
13The following third-party libraries are related to network requests: [Axios](https://gitee.com/openharmony-sig/axios), httpclient, and okdownload. For details, see the [OpenHarmony-TPC/tpc_resource repository](https://gitee.com/openharmony-tpc/tpc_resource).
14
15## How do I use ohpm to import third- and fourth-party libraries?
16
17Applicable to: OpenHarmony 3.1 Beta5 (API version 9)
18
19**Solution**
20
21-   Method 1:
22    1.  Open the **Terminal** window and run the following command to go to the **entry** directory:
23
24        ```
25        cd entry
26        ```
27
28    2.  Run the following command to install a third-party library, for example, **dayjs**:
29
30        ```
31        ohpm install dayjs
32        ```
33
34    3.  Add the following statement in the .js file to import the third-party library:
35
36        ```
37        import dayjs from 'dayjs';
38        ```
39
40
41-   Method 2:
42    1.  Enter the **entry** directory of the project and open the **oh-package.json5** file.
43    2.  Write the third-party library to be installed (for example, **dayjs**) in the **oh-package.json5** file.
44
45        ```
46        {
47          "dependencies": {
48            "dayjs": "^1.10.4",
49          }
50        }
51        ```
52
53    3.  Open the **Terminal** window and run the following command to go to the **entry** directory:
54
55        ```
56        cd entry
57        ```
58
59    4.  Run the following command to install the third-party library:
60
61        ```
62        ohpm install
63        ```
64
65    5.  Add the following statement in the .js file to import the third-party library:
66
67        ```
68        import dayjs from 'dayjs';
69        ```
70