Flutter开发HarmonyOS鸿蒙Next应用的时候提示vscode运行编译报错, 找不到命令ohpm
Flutter开发HarmonyOS鸿蒙Next应用的时候提示vscode运行编译报错, 找不到命令ohpm
【任务描述】
运行编译报错
vscode运行通过flutter create --platforms ohos my_app
创建的工程,报错如下:
Launching lib/main.dart on 127.0.0.1:5555 in debug mode…
main.dart:1
start hap build…
ProcessException: Failed to find “ohpm” in the search path.
Command: ohpm
Exited
命令行中ohpm可以正常运行 ➜ my_app ohpm Usage: ohpm [command] [options]
Options: -v, --version output the ohpm version -h, --help display help for command
Commands: config Manage the ohpm configuration file info Display the information about a package init Create an oh-package.json5 file install Install package(s) list Display the dependency tree ping Test the network connectivity to registry prepublish Pre-verification package content publish Publish a package to the registry uninstall Uninstall package(s) unpublish Unpublish a package from target registry update Update package(s) to their latest version based on the specified range root Print the effective oh_modules folder to standard out version Bump a package version cache Manage the ohpm cache folder run Run user defined package scripts, the optional parameter ‘args’ is used to append or override script parameters in the form ‘(-key/–key value), (-key/–key=value), (-key/–key=a=b)’ clean Delete all ‘oh_modules’ directories and the ‘oh-package-lock.json5’ file in the current project dist-tags Manage version tags of package convert Convert all the packages to the ohpm packages help display help for command
伙伴你好,请flutter doctor -v 检查一下环境是否正常
我也遇到这个问题,还没解决呢
在Flutter开发HarmonyOS鸿蒙Next应用时,如果遇到VSCode运行编译报错提示“找不到命令ohpm”,这通常表明OHPM(OpenHarmony Package Manager)工具未正确安装或未配置在系统路径中。OHPM是OpenHarmony中用于管理包和依赖的工具,类似于其他系统中的npm或yarn。
解决此问题的步骤如下:
-
确认OHPM安装:确保OHPM已在你的开发环境中安装。OHPM通常随OpenHarmony SDK一起安装。
-
环境变量配置:检查系统环境变量,确保OHPM的安装路径已添加到PATH中。这允许你在命令行中全局访问ohpm命令。
-
重新启动VSCode:修改环境变量后,重启VSCode以确保新的环境变量生效。
-
检查VSCode配置:确保VSCode的终端使用的是正确的shell环境,特别是如果你在Windows上使用了WSL(Windows Subsystem for Linux)或其他兼容层。
-
重新运行编译:在VSCode中重新尝试运行和编译你的Flutter应用。
如果问题依旧没法解决请联系官网客服,官网地址是:https://www.itying.com/category-93-b0.html