错误:无法加载文件 D:\,因为在此系统上禁止运行脚本。
json-server : 无法加载文件 D:\ruanjian\nodejs\node_global\json-server.ps1,因为在此系
统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170
中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ json-server ./04test.json --watch
+ ~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
解决方案:
以管理员身份运行vscode :
右键vscode,在属性中选择兼容性,勾选以管理员身份运行此程序;
1.在终端输入命令查看状态:
get-ExecutionPolicy
结果为:
Restricted
2. 输入命令改变其禁止状态:
set-ExecutionPolicy RemoteSigned;
3.再次查看状态:
get-ExecutionPolicy
结果为:
RemoteSigned
4.最后:
json-server ./04test.json --watch
结果为:
仅代表我遇到的问题及解决方案,如果不能解决请另寻他法。