Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
CaiPeng1989 opened this issue Jan 13, 2019 · 5 comments
Closed

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

CaiPeng1989 opened this issue Jan 13, 2019 · 5 comments
Labels

Comments

@CaiPeng1989
Copy link

CaiPeng1989 commented Jan 13, 2019

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

@sodatea
Copy link
Member

sodatea commented Jan 13, 2019

Possible related: yarnpkg/yarn#6902

@CaiPeng1989
Copy link
Author

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

@sodatea
Copy link
Member

sodatea commented Mar 15, 2019

原 issue 已在 Yarn 1.15.2 中修复。

vue upgrade 的问题近期会修掉。

@sodatea sodatea closed this as completed Mar 15, 2019
@Wxh16144
Copy link

Thank you. That solved my problem

@mazhili0321
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants