纱线已安装但不起作用。命令被识别,但没有任何纱线命令执行任何操作。Windows Powershell

Ham*_*obe 3 powershell npm-install yarnpkg

节点版本 11.13.0 npm 版本 6.9.0 我已经通过多种方式安装了纱线,首先使用npm install -g yarn,然后我尝试了 .msi 安装程序,我还尝试从提升的 shell 中使用 Chocolatey 安装。通常,当我尝试使用尚未安装的东西时,我会收到如下消息:

  PS C:\Users\[me]> hello
hello : The term 'hello' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ hello
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (hello:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)

然而,yarn命令被识别但不执行任何操作。

PS C:\Users\[me]> yarn --version
PS C:\Users\[me]>
Run Code Online (Sandbox Code Playgroud)

我尝试更改 Path 环境变量以包含以下内容:

C:\Users\[me]\AppData\Local\Yarn\bin
C:\Program Files (x86)\Yarn
C:\Program Files (x86)\Yarn\bin
Run Code Online (Sandbox Code Playgroud)

但这并没有改变任何事情。

Dan*_*dar 14

您必须在环境路径中添加 %USERPROFILE%\AppData\Roaming\npm

1-开始菜单中搜索环境 https://i.stack.imgur.com/y4zxD.jpg

2-单击环境变量 https://i.stack.imgur.com/B59yD.jpg

3-编辑用户变量的路径 https://i.stack.imgur.com/Vz73p.jpg

4-添加纱线的 URI 作为新的 https://i.stack.imgur.com/Rq7xK.jpg

然后,如果无法在 vscode 中使用yarn命令并收到错误yarn.ps1无法加载,因为在此系统上禁用了运行脚本;以管理员身份打开 Powershell 并运行以下命令

设置执行策略不受限制