赞
踩
ohpm has not been initialized yet.Execute the init script to initialize it first.
我本地node版本较老,切换node版本。
例如可切换到node 16
- ksnowlv@MacBook-Pro-3 base_demo % ohpm install @ohos/PullToRefresh
- ERROR: ohpm has not been initialized yet. Execute the init script to initialize it first.
- ksnowlv@MacBook-Pro-3 base_demo % nvm ls
- -> v10.24.1
- v16.20.2
- system
- default -> 10.24.1 (-> v10.24.1)
- iojs -> N/A (default)
- unstable -> N/A (default)
- node -> stable (-> v16.20.2) (default)
- stable -> 16.20 (-> v16.20.2) (default)
- lts/* -> lts/iron (-> N/A)
- lts/argon -> v4.9.1 (-> N/A)
- lts/boron -> v6.17.1 (-> N/A)
- lts/carbon -> v8.17.0 (-> N/A)
- lts/dubnium -> v10.24.1
- lts/erbium -> v12.22.12 (-> N/A)
- lts/fermium -> v14.21.3 (-> N/A)
- lts/gallium -> v16.20.2
- lts/hydrogen -> v18.20.2 (-> N/A)
- lts/iron -> v20.13.0 (-> N/A)
- ksnowlv@MacBook-Pro-3 base_demo % nvm use 16
- Now using node v16.20.2 (npm v8.19.4)
ohpm install @ohos/pulltorefresh Sorry, 报错 name contains invalid characters
ohpm init
执行后,重新手动输入ohpm install @ohos/pulltorefresh
- ksnowlv@MacBook-Pro-3 base_demo % ohpm init
- ksnowlv@MacBook-Pro-3 base_demo % ohpm install @ohos/pulltorefresh
- ohpm INFO: fetch meta info of package '@ohos/pulltorefresh' success https://repo.harmonyos.com/ohpm/@ohos/pulltorefresh
- ohpm INFO: fetch package done 1 @ohos/pulltorefresh https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_DevEcoSpace_901_9/af/v3/154e3006-30bb-4951-82df-57abe0ffda37/pulltorefresh-2.0.5.har
- install completed in 0s 509ms
- hvigor ERROR: The compatibleSdkVersion 9 cannot be smaller than version 10 declared in library [:library]
- as the library might be using APIS not available in 9
• oh-package.json5 中@ohos/pulltorefresh的版本降级为2.0.1
- {
- "name": "base_demo",
- "version": "1.0.0",
- "description": "Please describe the basic information.",
- "main": "",
- "author": "",
- "license": "",
- "dependencies": {
- "@ohos/pulltorefresh": "^2.0.1"
- },
- "devDependencies": {
- "@ohos/hypium": "1.0.6"
- }
- }
修改为
- {
- "name": "base_demo",
- "version": "1.0.0",
- "description": "Please describe the basic information.",
- "main": "",
- "author": "",
- "license": "",
- "dependencies": {
- "@ohos/pulltorefresh": "2.0.1"
- },
- "devDependencies": {
- "@ohos/hypium": "1.0.6"
- }
- }
升级HUAWEI DevEco Studio
到4.0,同时API升级到10
如果你想快速提升鸿蒙技术,那么可以直接领取这份包含了:【OpenHarmony多媒体技术、Stage模型、ArkUI多端部署、分布式应用开发、音频、视频、WebGL、Napi组件、OpenHarmony内核、Harmony南向开发、鸿蒙项目实战】等技术知识点。
鸿蒙Next全套VIP学习资料←点击领取!(安全链接,放心点击)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。