vue-cli: Vue CLI fails on Windows Powershell
Version
3.4.0
Environment info
Environment Info:
System:
OS: Windows 10
CPU: (16) x64 AMD Ryzen 7 1700X Eight-Core Processor
Binaries:
Node: 11.9.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.13.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.5.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 44.17763.1.0
npmGlobalPackages:
@vue/cli: Not Found
Steps to reproduce
Install Vue CLI using npm by running npm i -g @vue/cli
Open powershell as either standard or admin user.
run vue create test in powershell
What is expected?
Vue should run its cli to create a new project without errors
What is actually happening?
Vue CLI fails in only powershell due to apparent syntax errors. It appears to work fine in cmd.
PS C:\Users\natty> vue create test
At C:\Users\natty\AppData\Local\Yarn\bin\vue.ps1:5 char:13
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
~
Unexpected token ')' in expression or statement.
At C:\Users\natty\AppData\Local\Yarn\bin\vue.ps1:8 char:3
if [ -x "$basedir/pwsh" ]; then
~
Missing '(' after 'if' in if statement.
At C:\Users\natty\AppData\Local\Yarn\bin\vue.ps1:8 char:5
if [ -x "$basedir/pwsh" ]; then
~
Missing type name after '['.
At C:\Users\natty\AppData\Local\Yarn\bin\vue.ps1:9 char:20
... sedir/pwsh" "$basedir/../Data/global/node_modules/.bin/vue.ps1" "$@"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token '"$basedir/../Data/global/node_modules/.bin/vue.ps1"' in expression or statement.
At C:\Users\natty\AppData\Local\Yarn\bin\vue.ps1:9 char:72
... sedir/pwsh" "$basedir/../Data/global/node_modules/.bin/vue.ps1" "$@"
~~~~
Unexpected token '"$@"' in expression or statement.
CategoryInfo : ParserError: (:) [], ParseException
FullyQualifiedErrorId : UnexpectedToken
PS C:\Users\natty>
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 28 (1 by maintainers)
my work-around: Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
It might be slightly misleading to use NPM in the “Steps to reproduce” when the issue is related to a specific version of Yarn.
Also, to circumvent the issue until it is fixed, you can just call the
.cmd-shim directly to avoid the faulty PowerShell-shim, i.e.vue.cmd create test.run this command: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
You can navigate to where the global vue-cli is installed and delete the vue.ps1 file, leaving the vue.cmd file – then things work fine. It’s a work-around for now, I guess.
From: Domenico Marescamailto:notifications@github.com Sent: Thursday, November 28, 2019 4:33 AM To: vuejs/vue-climailto:vue-cli@noreply.github.com Cc: jason-e-grossmailto:jason.e.gross@outlook.com; Commentmailto:comment@noreply.github.com Subject: Re: [vuejs/vue-cli] Vue CLI fails on Windows Powershell (#3424)
vue : File C:\Users\jason\AppData\Roaming\npm\vue.ps1 cannot be loaded. The file C:\Users\jason\AppData\Roaming\npm\vue.ps1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1
This issue seems to have reared its head again, but this time - nothing to do with Yarn. I was bashing my head against the wall because all searches point to Yarn - but:
Remove Node from system entirely, deleting global module folders, also.
Reinstall Node.
“npm install -g @vue/cli” - let it do its thing
Type “Vue” on a powershell window, and you get the error above.
I don’t have Yarn in my system, and installed Vue/CLI with NPM. I get this issue. Renaming the vue.ps1 to something else so the “Vue” call uses the .cmd file fixes the issue - but out of the box, the vue cli will not work in PowerShells (the default inside the VS IDE, so that’s definitely an issue).
I have the same issue today on a clean system
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/vuejs/vue-cli/issues/3424?email_source=notifications&email_token=AD54Y7CFQHOF2ZMFLNL6CPLQV6NADA5CNFSM4GURRP4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFMFSZI#issuecomment-559438181, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AD54Y7BQFGC6IJKMKJ377YTQV6NADANCNFSM4GURRP4A.
The title of this issue is much more clear than the one of the other duplicate. Also, I don’t speak chinese 😃
Thanks for the info. The temporary solution is to roll back to yarn
1.12.3(and reinstall vue cli).vue : File C:\Users\jason\AppData\Roaming\npm\vue.ps1 cannot be loaded. The file C:\Users\jason\AppData\Roaming\npm\vue.ps1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1This issue seems to have reared its head again, but this time - nothing to do with Yarn. I was bashing my head against the wall because all searches point to Yarn - but:
I don’t have Yarn in my system, and installed Vue/CLI with NPM. I get this issue. Renaming the vue.ps1 to something else so the “Vue” call uses the .cmd file fixes the issue - but out of the box, the vue cli will not work in PowerShells (the default inside the VS IDE, so that’s definitely an issue).
What I had to do on Windows 11 (and maybe applies to 10): 1.)
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser2.)npm install -g @vue/cliThis one is better since the scope is limited to the current shell. The other proposal seams to disable security checks for the whole user.
this is work for me. thanks
I have the same issue today on a clean system
I don’t know if this is your issue, but I just removed it globally with yarn and re-installed it globally with npm (via admin). Everything works perfectly now; a .ps1 file was not downloaded, leaving the .cmd as the only option.
npm i --global vue-cli
This was giving me a major headache for the past 45 minutes…