5

Windows 鸿蒙环境搭建 hpm 报错:无法加载文件 hpm.ps1,因为在此系统上禁止运行脚本

 3 years ago
source link: https://xmanyou.com/hpm-cannot-run-securityerror-unauthorizedaccess/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
16 February 2021 / 鸿蒙

Windows 鸿蒙环境搭建 hpm 报错:无法加载文件 hpm.ps1,因为在此系统上禁止运行脚本

按照官方文档,成功安装了hpm。

执行以下命令来检查hpm是否安装成功

hpm -V

结果报错:

hpm : 无法加载文件 C:\Users\abin\AppData\Roaming\npm\hpm.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/g
o.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ hpm -V
+ ~~~
    + CategoryInfo          : SecurityError: (:) [],PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

hpm-cannot-run-SecurityError-UnauthorizedAccess-01

  • 1). 以管理员权限运行powershell
  • 2). 执行命令 set-executionpolicy remotesigned
set-executionpolicy remotesigned

执行策略更改
执行策略可帮助你防止执行不信任的脚本。更改执行策略可能会产生安全风险,如 https:/go.microsoft.com/fwlink/?LinkID=135170
中的 about_Execution_Policies 帮助主题所述。是否要更改执行策略?
[Y] 是(Y)  [A] 全是(A)  [N] 否(N)  [L] 全否(L)  [S] 暂停(S)  [?] 帮助 (默认值为“N”): Y

hpm-cannot-run-SecurityError-UnauthorizedAccess-02

  • 3). 重新执行hpm -V命令,此时应该没有报错,并打印出hpm的版本信息。

hpm-cannot-run-SecurityError-UnauthorizedAccess-03

阿斌

Read more posts by this author.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK