Skip to content

无法加载文件 %AppData%\Local\Yarn\bin\vue.ps1 #3293

@CaiPeng1989

Description

@CaiPeng1989

Version

3.3.0

Environment info

node: v11.6.0
yarn: 1.13.0
npm: 6.6.0
windows10: 17763.253

Steps to reproduce

使用yarn的独立安装包安装yarn

yarn global add @vue/cli
vue -V

powershell输出如下:

vue : 无法加载文件 %AppData%\Local\Yarn\bin\vue.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
vue -V
CategoryInfo : SecurityError: (:) [],PSSecurityException
FullyQualifiedErrorId : UnauthorizedAccess

在网上搜索使用如下方法:

以管理员身份打开PowerShell
输入Set-ExecutionPolicy RemoteSigned,执行策略更改

再次执行:

vue -V

powershell 输出如下:

所在位置 C:\Users\MengQing\AppData\Local\Yarn\bin\vue.ps1:5 字符: 13
CYGWIN) basedir=cygpath -w "$basedir";;
~
表达式或语句中包含意外的标记“)”。
所在位置 %AppData%\Local\Yarn\bin\vue.ps1:8 字符: 3
if [ -x "$basedir/pwsh" ]; then
~
if 语句中的“if”后面缺少“(”。
所在位置 C:\Users\MengQing\AppData\Local\Yarn\bin\vue.ps1:8 字符: 5
if [ -x "$basedir/pwsh" ]; then
~
"[" 后面缺少类型名称。
所在位置 C:\Users\MengQing\AppData\Local\Yarn\bin\vue.ps1:9 字符: 20
... sedir/pwsh" "$basedir/../Data/global/node_modules/.bin/vue.ps1" "$@"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
表达式或语句中包含意外的标记“"$basedir/../Data/global/node_modules/.bin/vue.ps1"”。
所在位置 C:\Users\MengQing\AppData\Local\Yarn\bin\vue.ps1:9 字符: 72
... sedir/pwsh" "$basedir/../Data/global/node_modules/.bin/vue.ps1" "$@"
~~~~
表达式或语句中包含意外的标记“"$@"”。
CategoryInfo : ParserError: (:) [], ParseException
FullyQualifiedErrorId : UnexpectedToken

cmd能够正常输出。

What is expected?

powershell下正常执行命令

What is actually happening?

抛出错误


如果通过npm安装yarn

yarn global add @vue/cli
vue -V

则会得到:

vue不是内部或外部命令,也不是可运行的程序或批处理文件。

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions