npm install初始化出现问题: npm ERR! Unsupported URL Type "workspace:": workspace:*

1. 在拉取项目之后,npm install 初始化报错

npm ERR! Unsupported URL Type "workspace:": workspace:*

2. 检查package.json中是否出现过[workspace:],如果有,并出现上述问题,可以安装yarn来解决

3. 解决方案

1. 安装yarn

npm install -g yarn

2. 通过yarn install 来初始化

yarn install

3. 在使用yarn命令可能会出现以下错误

yarn : 无法加载文件 E:\softwareData\nodeData\node_global\yarn.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwli
nk/?LinkID=135170 中的 about_Execution_Policies。

导致此错误的原因是,PowerShell 执行策略,默认设置为Restricted不加载配置文件或运行脚本。需变更设置为RemoteSigned,变更过程为:

运行 Windows PowerShell(管理员),执行命令set-ExecutionPolicy RemoteSigned更改 PowerShell 执行策略,过程中提示询问是否要更改执行策略?,选择 A 或 Y 。如下图:

设置完毕,检验执行yarn config get registry命令,可正常加载执行脚本。

使用get-ExecutionPolicy命令,可查看当前 PowerShell 执行策略类型。

在vscode中执行 yarn install:

最后加载依赖包成功。 

参考:https://blog.csdn.net/hefeng_aspnet/article/details/126228274

posted @ 2022-12-20 16:48  落晴鸢  阅读(11665)  评论(0编辑  收藏  举报