Vue-cli: 无法加载文件 %AppData%\Local\Yarn\bin\vue.ps1

Created on 13 Jan 2019  ·  5Comments  ·  Source: vuejs/vue-cli

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不是内部或外部命令,也不是可运行的程序或批处理文件。

upstream

Most helpful comment

😂原来是yarn挖的坑,另外问下 vue upgrade 是不是只能通过 yarn 安装 @vue/cli @vue/cli-upgrade 才能运行,npm安装的不行。

All 5 comments

😂原来是yarn挖的坑,另外问下 vue upgrade 是不是只能通过 yarn 安装 @vue/cli @vue/cli-upgrade 才能运行,npm安装的不行。

原 issue 已在 Yarn 1.15.2 中修复。

vue upgrade 的问题近期会修掉。

Thank you. That solved my problem

我也遇到了这个问题,当我使用 PowerShell 的时候会出这个错,当我使用 Git Bash 的时候是正常的

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BusyHe picture BusyHe  ·  3Comments

OmgImAlexis picture OmgImAlexis  ·  3Comments

chasegiunta picture chasegiunta  ·  3Comments

sanderswang picture sanderswang  ·  3Comments

wahidrahim picture wahidrahim  ·  3Comments