1# 三四方库使用常见问题 2 3## 报错“Stage model module … does not support including OpenHarmony npm packages or modules in FA model. OpenHarmony build tasks will not be executed, and OpenHarmony resources will not be packed. ”如何解决 4 5适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 6 7三四方件未适配API9 Stage模型,无法使用。 8 9## 项目是否支持传递依赖 10 11适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 12 13比如项目A依赖项目B,项目B依赖项目C,那项目A是否能直接使用项目C提供的接口? 14 15不支持。由于项目打包使用npm工具,npm不支持传递依赖。可以在项目A增加项目C的依赖来解决问题。 16 17## 如何获取可用的三方库 18 19适用于:OpenHarmony SDK 3.2.6.5版本,API9 Stage模型 20 21参见:[OpenHarmony上可直接使用的三方组件汇总](https://gitee.com/openharmony-sig/third_party_app_libs)。 22 23## 网络相关的三方库有哪些 24 25适用于:OpenHarmony SDK 3.2.6.5版本,API9 Stage模型 26 27网络相关的三方库有[Axios](https://gitee.com/openharmony-sig/axios)。 28 29## 如何使用npm引入三四方库 30 31 适用于:OpenHarmony SDK 3.2.5.5版本,API9 Stage模型 32- 方法一: 33 1. 打开Terminal窗口,通过如下指令进入到entry目录。 34 35 ``` 36 cd entry 37 ``` 38 2. 以引入“dayjs”为例,执行以下指令进行安装。 39 40 ``` 41 npm install dayjs --save 42 ``` 43 3. 在对应的js文件中直接引用。 44 45 ``` 46 import dayjs from 'dayjs'; 47 ``` 48 49- 方法二: 50 1. 打开工程目录下的entry目录,找到该目录下的package.json文件。 51 2. 在package.json文件中写入想要安装的三方npm,以“dayjs”为例,示例如下: 52 53 ``` 54 { 55 "dependencies": { 56 "dayjs": "^1.10.4", 57 } 58 } 59 ``` 60 3. 打开Terminal窗口,通过如下指令进入到entry目录。 61 62 ``` 63 cd entry 64 ``` 65 4. 执行指令进行安装。 66 67 ``` 68 npm install 69 ``` 70 5. 在对应的js文件中直接引用。 71 72 ``` 73 import dayjs from 'dayjs'; 74 ``` 75