如何在Windows上安装pnpm?

huangapple go评论53阅读模式
英文:

How to install pnpm on Windows?

问题

看起来,如果我使用以下命令,pnpm可以正常安装:

```iwr https://get.pnpm.io/install.ps1 -useb | iex```

或者

```npm i -g pnpm```

但是,如果我想在同一个PowerShell中使用`pnpm --version`或者在VS Code PowerShell中使用它,会弹出Windows框,显示:

> 选择一个应用程序来打开 "pnpm"

或者如果我在VS Code PowerShell中使用它,什么都不会发生。

安装完成后,我可以看到用户环境变量`%PNPM_HOME%`已经添加到Path中。我尝试将它添加到系统环境变量的Path中,但仍然无法正常工作。

我漏掉了什么,以便能够使用它?

编辑:经过许多天后,我再次尝试,它奇迹般地正常工作了。我没有做任何更改 🤷‍♂️
英文:

It seems that pnpm installs fine if I use:

iwr https://get.pnpm.io/install.ps1 -useb | iex

or

npm i -g pnpm

But then if I want to use any command in the same PowerShell as pnpm --version I get the Windows box saying:

> select an app to open "pnpm"

Or if I use it in the VS Code PowerShell directly nothing happens.

After installation I can see that the user environment variable %PNPM_HOME% is added to Path. I've tried adding it in path to the system environment variable as well, but it still doesn't work.

What am I missing to be able to use it?

EDIT: I tried again after many days and it worked. I didn't change anything 🤷‍♂️

答案1

得分: 2

下载PowerShell脚本(https://get.pnpm.io/install.ps1),然后在PowerShell命令行中以管理员身份运行。

英文:

The option worked for me is download the PowerShell script(https://get.pnpm.io/install.ps1) and run in the powershell cli as admin

答案2

得分: 0

I also had the same problem. Solved with the method in this video

✅如何解决“因为在此系统上禁用了运行脚本,所以无法加载 PS1 错误”?已解决

Step 1: 首先,您需要打开命令提示符并运行此命令。

set-ExecutionPolicy RemoteSigned -Scope CurrentUser

当您运行此命令时,您会看到您的系统已将当前用户的所有策略设置为远程。完成此过程需要几秒钟。

Step 2: 现在您需要在您的系统上运行第二个命令。这个命令是:

Get-ExecutionPolicy

当您运行此命令时,您的系统会显示“RemoteSigned”。如果您收到这条消息,那么您的问题将得到解决。现在您需要继续下一步,查看最后一组命令更新的策略列表。

Step 3: 要查看策略,您需要在命令提示符中运行此命令:

Get-ExecutionPolicy -list

就是这样...问题解决了!

英文:

I also had the same problem. Solved with the method in this video

✅How To Fix Error PS1 Can Not Be Loaded Because Running Scripts Is Disabled On This System? SOLVED

Step 1: First, you have to need to open the command prompt and run this command.

set-ExecutionPolicy RemoteSigned -Scope CurrentUser

When you run this command, you can see that your system has set all policies for the current user as remotely. It will take few seconds to complete this process.

Step 2: Now you have to run the second command on your system. This command is:

Get-ExecutionPolicy

When you have run this command your system has a show “RemoteSigned”. If you have received this message, then your problem will be solved. Now you have to go to the next step to view the list of policies which policy has been updated by the last commands.

Step 3: To view their policy, you need to run this command in your command prompt:

Get-ExecutionPolicy -list

That's all... And there you go! Your problem got Solved!!

huangapple
  • 本文由 发表于 2023年2月7日 03:22:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/75365692.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定