Firebase-tools: npm i -g firebase-tools leads to ...firebase.ps1 cannot be loaded because running scripts is disabled on this system

Created on 27 Aug 2019  ·  44Comments  ·  Source: firebase/firebase-tools

I've come across the following error today after updating firebase-tools.
I use Visual Studio Code and after the latest firebase update I'm not able to run any firebase scripts in the PowerShell terminal.
I can run them in cmd and I can run other scripts still in PowerShell, eg npm and Netlify hosting.
I was using firebase in one project after deploying earlier today, got the prompt to update firebase-tools, did so, and now cant access firebase in any project from PowerShell.
Been using without issue for 6+months.

[REQUIRED] Environment info


// Can't run this command but package.json says:
"firebase": "^5.11.1",

Platform:
Windows 10 Home

[REQUIRED] Test case

  1. Install Visual Studio Code
  2. Open a new file/folder
  3. In terminal -
    npm install -g firebase-tools
  4. In PowerShell terminal -
    firebase // followed by any command
    leads to error :
    firebase : File C:\Users\mada7\AppData\Roaming\npm\firebase.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
    https:/go.microsoft.com/fwlink/?LinkID=135170.

[REQUIRED] Steps to reproduce

As above

[REQUIRED] Expected behavior

firebase to run scripts in powershell, which worked until updating firebase-tools to the latest version.

[REQUIRED] Actual behavior

// can't run with --debug flag in Powershell
PS C:\web-dev\cv> firebase
firebase : File C:\Users\mada7\AppData\Roaming\npm\firebase.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1

  • firebase
  • ~~~~

    • CategoryInfo : SecurityError: (:) [], PSSecurityException

    • FullyQualifiedErrorId : UnauthorizedAccess

// running in cmd
Microsoft Windows [Version 10.0.18362.295]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\web-dev\cv>firebase --debug
[2019-08-27T08:50:01.286Z] ----------------------------------------------------------------------
[2019-08-27T08:50:01.290Z] Command: C:\Program Files\nodejs\node.exe C:\Users\mada7\AppData\Roaming\npmnode_modulesfirebase-tools\lib\bin\firebase.js --debug
[2019-08-27T08:50:01.291Z] CLI Version: 7.2.4
[2019-08-27T08:50:01.291Z] Platform: win32
[2019-08-27T08:50:01.292Z] Node Version: v10.16.3
[2019-08-27T08:50:01.293Z] Time: Tue Aug 27 2019 09:50:01 GMT+0100 (British Summer Time)
[2019-08-27T08:50:01.293Z] ----------------------------------------------------------------------

Usage: firebase [options] [command]

Most helpful comment

I have the same error.
Temp solution:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser

All 44 comments

@abeisgoat any idea what's going on here? This is a Windows thing, so I am therefore automatically scared of it.

I have the same error.
Temp solution:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser

I have the same error.
Temp solution:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser

is it safe?

I have the same error.
Temp solution:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser

is it safe?

Unfortunately it's not safe. If you choose use this police very careful when use package manager like chocolatey.

So, I updated vue.js later in that day and got errors running those scripts too.
Posted the problem on the Vue forum and got directed to Stackoverflow, a user on there replied with a similar workaround, which I've reluctantly done.
https://stackoverflow.com/questions/57673913/vsc-powershell-after-npm-updating-packages-ps1-cannot-be-loaded-because-runnin

Ran into this issue updating from 7.3.1 to 7.3.2

I have the same error.
Temp solution:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser

It's a good solution and works for me.

I have the same error.
Temp solution:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser

is it safe?

Unfortunately it's not safe. If you choose use this police very careful when use package manager like chocolatey.

Well, try this:

PS C:> Set-ExecutionPolicy RemoteSigned

Then run your chosen firebase syntax command.

used this Set-ExecutionPolicy RemoteSigned that work for me.
thanks

After the effort, I think Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser is good option to fix the issue.you can go with this it will not create issue.

If you try to generate command on cmd it will be work instead of VS Code Terminal.

Remove ng.ps1(respective ps1 file) from the directory C:\Users\< username >\AppData\Roaming\npm\ then try clearing the npm cache at C:\Users\< username >\AppData\Roaming\npm-cache..

this worked for me

Remove firebase.ps1(respective ps1 file) from the directory C:\Users< username >\AppData\Roaming\npm\ then try clearing the npm cache at C:\Users< username >\AppData\Roaming\npm-cache.. ( npm cache clean --force )

this worked for me

Remove ng.ps1(respective ps1 file) from the directory C:\Users< username >\AppData\Roaming\npm\ then try clearing the npm cache at C:\Users< username >\AppData\Roaming\npm-cache..

this worked for me

@rajachennupati's way 100% works. Do what he said above and delete that .ps1 file (aka Windows Powershell Script) and then run the command npm cache clean.

@nvrr Do npm cache clean --force this will for sure remove everything from cache. If you are not comfortable with cleaning your entire cache. I suggest doing some research on how to do it more safely.

I have the same error.
Temp solution:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser

it worked

Can someone close this issue??

I have the same error.
Temp solution:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser

It's a good solution and works for me.

I have the same error.
Temp solution:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser

it worked

this worked for me..thanks >>> Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser

Allow remote signed scripts for current user:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Could we get someone smart to explain why Set-ExecutionPolicy RemoteSigned -Scope CurrentUser solves the issue, and why so many of us are getting errors in the first place?

It worked for me too btw.

@HeyAshh exactly. Feels like this issue hasn't actually been solved only a workaround provided. In that case, it should be reopened and fixed.

The documentation from Microsoft is here:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7

It seems that in some cases PowerShell blocks "scripts". I am not sure what qualifies the Firebase CLI as a script under this policy or if we have done anything to change it recently but I don't think there is anything we can do to change this very system/shell specific behavior. If anyone has an idea we'd love to hear it though!

Also for users having this issue: do you have the same issue with other node-based CLIs? If you npm install -g prettier are you able to runprettier afterwards?

I was able to run the firebase command using git bash without any problem

Hi i solved this error with change of running Script terminal.
I run it on power Shell 1 terminal and then i switch to next

Hey Deleting the firebase.ps1 file at the mentioned location worked for me without compromising security, hope it helps

it makes me wonder why this bug is still a thing

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Use this one for same problem it is somehow safe

@k96white Yes deleting firebase.ps1 file definitely helped

If you try to generate command on cmd it will be work instead of VS Code Terminal.

It also works if you are in your git bash, haven't tried just Powershell, think it is a VS Code issue.

I have the same error.
Temp solution:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser

yes it's working thanks

hi

On Sun, May 31, 2020 at 12:11 AM anuj agarwal notifications@github.com
wrote:

I have the same error.
Temp solution:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser

yes it's working thanks


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/firebase/firebase-tools/issues/1627#issuecomment-636386066,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ANW5CJADO725ZF6F2OERJWTRUFZB7ANCNFSM4IQA4I4A
.

Remove ng.ps1(respective ps1 file) from the directory C:\Users< username >\AppData\Roaming\npm\ then try clearing the npm cache at C:\Users< username >\AppData\Roaming\npm-cache..

this worked for me

Works perfect without other issues.

make sure you use cmd bash instead of powershell in vscode , that worked for me;)

This is only on built-in VSCode terminal in windows default CMD it just works fine.

"terminal.integrated.shellArgs.windows": ["-ExecutionPolicy", "Bypass"],
.
.
Try this one inside PREFERENCES settings -> Search Automation and add inside this"Terminal › Integrated › Automation Shell: Linux" -> ADD NEW "terminal.integrated.shellArgs.windows": ["-ExecutionPolicy", "Bypass"], THIS

I used Powershell Integrated console for vscode and it seems to work perfectly fine

C:\Users{username}\AppData\Roaming\npm\firebase.ps1
I deleted this file and it works for me.

The documentation from Microsoft is here:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7

It seems that in some cases PowerShell blocks "scripts". I am not sure what qualifies the Firebase CLI as a script under this policy or if we have done anything to change it recently but I don't think there is anything we can do to change this very system/shell specific behavior. If anyone has an idea we'd love to hear it though!

Also for users having this issue: do you have the same issue with other node-based CLIs? If you npm install -g prettier are you able to runprettier afterwards?

Nope... Not able to run Prettier or ES7 snippets. Now it threw an exception to deploy the project on Firebase as well... Looking for a safe alternative.

well I read something on StackOverflow and that worked for me
and that's it :

"Just delete firebase.ps1 file"

I have the same error.
Temp solution:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser

its worked for me thanks...

Remove ng.ps1(respective ps1 file) from the directory C:\Users< username >\AppData\Roaming\npm\ then try clearing the npm cache at C:\Users< username >\AppData\Roaming\npm-cache..

this worked for me

It's 100% working. Thanks but still I didn't get it what just happened.

C:\Users{username}\AppData\Roaming\npm\firebase.ps1
I deleted this file and it works for me.

Yes this worked for me too

Just delete the file

C:\Users{username}\AppData\Roaming\npm\firebase.ps1
I deleted this file and it works for me.

Yes this worked for me too

This solved the problem for me as well

Was this page helpful?
0 / 5 - 0 ratings