npm: 无法加载文件

简单例子:

image

 

在VSCODE终端窗口里运行 编译 TYPESCIPT脚本时(node hello.ts),提示 :npm: 无法加载文件 D:\Program Files\Nodejs\node_global\nmp.ps1, 因为在此系统禁止运行脚本。

>node hello.ts 

image

 解决方式:

1)、打开WIN 的 posershell 命令窗口,按顺序

>get-ExecutionPolicy   // 查权限状态

>set-ExecutionPolicy  // 设置权限

ExecutionPolicy: RemoteSigned  

image

 

设置后,重新启动VSCODE,编译 typescript 脚本:

image

可以看输出结果: 

hello world .

 

posted @ 2025-11-09 21:29  samrv  阅读(4)  评论(0)    收藏  举报