当前位置:网站首页>输入cnpm -v出现cnpm : 无法加载文件 C:\Users\19457\AppData\Roaming\npm\cnpm.ps1,因为在此系统上禁止运行脚本。
输入cnpm -v出现cnpm : 无法加载文件 C:\Users\19457\AppData\Roaming\npm\cnpm.ps1,因为在此系统上禁止运行脚本。
2022-07-24 02:16:00 【柠檬气泡水~】
今天安装完cnpm,查看版本时报错如下:
cnpm : 无法加载文件 C:\Users\19457\AppData\Roaming\npm\cnpm.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execu
tion_Policies。
所在位置 行:1 字符: 1
+ cnpm -v
+ ~~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

解决办法:
1、windows+r输入PowerShell
2、输入 set-ExecutionPolicy RemoteSigned回车
3、根据提示,输入A,回车
4、再输入 get-ExecutionPolicy直到看到RemoteSigned就成功了。
如果第2步中输入“ set-ExecutionPolicy RemoteSigned”回车报错如下:
set-ExecutionPolicy : 对注册表项“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell”的
访问被拒绝。 要更改默认(LocalMachine)作用域的执行策略,请使用“以管理员身份运行”选项启动 Windows PowerShell。要更改当
前用户的执行策略,请运行 "Set-ExecutionPolicy -Scope CurrentUser"。
所在位置 行:1 字符: 1
+ set-ExecutionPolicy RemoteSigned
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (:) [Set-ExecutionPolicy], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecutionPolicyComma
nd

解决办法:
1、根据提示输入Set-ExecutionPolicy -Scope CurrentUser
回车以后,输入remotesigned

2、输入Y

3、再次输入 get-executionpolicy 查看 是否解除限制
显示 RemoteSigned 显示成功

ps:不只是cnpm命令,包括pnpm、yarn等这些命令,如果执行时,报这样的错误,都可以通过此方法解决。前提是,如果是用npm命令来安装这些CLI命令工具,必须安装到全局环境中,才能生效。
边栏推荐
- 快速排序注意点
- Quick sort considerations
- [Luogu] p1318 ponding area
- Research and analysis of the third-party dependency library Ag grid
- WordPress website SEO complete tutorial
- Halide::Generator生成器使用说明
- Tensorflow 2.0 deep learning tutorial
- MySQL---four JDBC
- Use of component El scrollbar
- What's new in the ranking list in July? This language is invincible?
猜你喜欢

Responsive layout a web page displays different effects on different devices) meta:vp

Visual full link log tracking

Study and use of burpsuite plug-in

浅谈元宇宙中DeFi的可能性和局限性

Study and use of windows security defect detection tool wesng

1000个Okaleido Tiger首发上线Binance NFT,引发抢购热潮

How to install, download and use the latest version of IDM software

Excel simple macro

图解数组和链表详细对比,性能测试

Try to run this command from the system terminal Make sure that you use the correct
随机推荐
Magazine feature: the metauniverse will reshape our lives, and we need to make sure it gets better
Install go environment under Kali
什么叫裸写SQL?express操作mysql用什么中件间或插件好呢?
分布式资源管理与任务调度框架Yarn
餐饮连锁门店重塑增长背后的数字化转型
Writing of graph nodes that trigger different special effects during the day and at night in Tiktok
利用canvas画图片
网络协议详解 :UDP
[MySQL] character set utf8mb4 cannot store the record of expression stepping on the pit
暗黑系王者,低照度图像增强技术解析
Network protocol details: UDP
NetApp FAS系列一个CIFS bug引起的控制器重启案例分享
pbootcms模板调用标签序数从2开始或者自动数开始
What is naked SQL? What middleware or plug-in is good for express to operate MySQL?
Bank of Nanjing approved the financial technology post in advance
Idea's gradle project Chinese garbled
Structure the second operation of the actual combat battalion module
以科技传递温度,vivo守护生物多样性之美
BPG笔记(三)
NetCore-如何保证ICollection或List私有化不被外部修改?