136

I design websites in VSC and PowerShell is my default terminal.

After updating and deploying a website to firebase earlier, I was prompted to update firebase tools - which I did using npm. Immediately after I cannot run/access any firebase scripts wthout the folllowing 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. At line:1 char:1

firebase + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess

I've spent a few hours searching around and can't find a solid answer the problem. Many threads are several years old and I find it bizarre I've not had this problem in the past year until today. I can still access firebase scripts if I set my default terminal to cmd.

Assuming the problem was related to firebase-tools I've carried on working but have now updated vue.js and get the error again when trying to run any vue commands in powershell:

vue : File C:\Users\mada7\AppData\Roaming\npm\vue.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

vue + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess

VSCode Version: Version: 1.37.1 (user setup) Commit: f06011a Date: 2019-08-15T16:17:55.855Z Electron: 4.2.7 Chrome: 69.0.3497.128 Node.js: 10.11.0 V8: 6.9.427.31-electron.0 OS: Windows_NT x64 10.0.18362 OS Version: Windows 10 Home Version - 1903 OS build - 18362.295

I've been reading around and seen many threads around permissions for scripts, but I haven't changed any - indeed the PowerShell scripts worked right up until I updated my packages. No other settings touched in the mean time. I don't want to be changing PowerShell settings unnecessarily.

Aponting
  • 1,361
  • 2
  • 7
  • 6
  • 2
    This problem started for several application using npm around November of 2019. It's then that npm started using powershell scripts. See [this](https://github.com/npm/read-cmd-shim/pull/6) npm pull request and this subsequent npm issue 470. https://github.com/npm/cli/issues/470 – Troy Witthoeft Apr 13 '20 at 19:38

23 Answers23

229

This is a powershell security policy, to fix it, run Powershell as administrator and run the following

PS C:\> Set-ExecutionPolicy RemoteSigned 

If you don't want to run the command as an administrator but just for the current user, you can add a scope like below

PS C:\> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

The stricter the policy, the more secure your system becomes.

You can change RemoteSigned to other options like: Restricted, AllSigned, RemoteSigned, Unrestricted

Source: https://tecadmin.net/powershell-running-scripts-is-disabled-system/

Alternatively you can modify C:\Program Files\PowerShell\7\powershell.config.json using a text editor and add or modify the following section.

{
   ....

   "Microsoft.PowerShell:ExecutionPolicy":  "RemoteSigned"
}

You can also run your script without modifying security policies by using the command prompt as noted by ztom's answer here.

tushortz
  • 3,697
  • 2
  • 18
  • 31
  • Thanks for the reply. I had actually already come across that website and am reluctant to change anything as the error came about without me changing anything or installing/restarting the computer. I have now changed my settings in PowerShell and it runs scripts as before, is there anything I should be concerned with having changed this? I originally posted the question on gitHub and a couple of people have the same issue. https://github.com/firebase/firebase-tools/issues/1627 – Aponting Aug 31 '19 at 08:19
  • @Aponting As long as you don’t have malicious software on your pc that may route data to an external server, it should be fine. Better to also have an antivirus installed but I don’t think it’s too much to worry about if you don’t use dodgy websites or software – tushortz Sep 01 '19 at 09:31
  • Executing `Set-ExecutionPolicy RemoteSigned` in the windows powershell works now. Thank you. –  Feb 22 '20 at 13:15
224

Just delete firebase.ps1 file:

File C:\Users\<your account>\AppData\Roaming\npm\firebase.ps1

Andrew Bullock
  • 36,616
  • 34
  • 155
  • 231
Drashyr
  • 2,355
  • 1
  • 4
  • 7
29

A little clarification: when you run PowerShell as Admin, in most cases you don't need to note a path. Just type:

Set-ExecutionPolicy RemoteSigned

then press "A", then "Enter"

Ivan Zagainov
  • 350
  • 4
  • 6
15

Also, one thing worth mentioning is that you need to open PowerShell as Admin and then change the policy like so.

PS C:\> Set-ExecutionPolicy RemoteSigned

Reference - Using the Set-ExecutionPolicy Cmdlet

Bruno Zorima
  • 151
  • 3
14

I didn't have any problem with npm but the same problem is in the using yarn on windows. In my case, I deleted yarn.ps1 and it worked fine for me:

File path:

C:\Users\<your account>\AppData\Roaming\npm\yarn.ps1
J. M. Arnold
  • 6,261
  • 3
  • 20
  • 38
14

For those who work with VS Code and get the about_Execution_Policies error. In my case with the command ncu -u (npm-check-updates).

Try it with CMD:

enter image description here

Simply execute the command in CMD again.

If this works, the security settings can remain as they are.

tom
  • 9,550
  • 6
  • 30
  • 49
10
  1. search for powershell.

  2. right click and run as administration.

  3. run this simple command Set-ExecutionPolicy RemoteSigned.

  4. Press A And Enter.

  5. go to code and run yarn add <YOUR_MODULE>.

  6. press Enter.

congratulations now it would be done.

Sahil bakoru
  • 393
  • 1
  • 4
  • 10
9

This could be due to the current user having an undefined ExecutionPolicy.

You could try the following

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted

Emrah AKIN
  • 137
  • 1
  • 6
5

I also had this problem in the powershell and i used the following : then i again installed the serve package.

 Set-ExecutionPolicy -Scope CurrentUser

and then i chose Unrestricted and gave serve command and it worked.

Rohan Devaki
  • 2,931
  • 1
  • 14
  • 22
4

File C:\Users\xxxx\AppData\Roaming\npm\vue.ps1 cannot be loaded because running scripts is disabled on this system.

I had the same error message with vue. After running the below command successfully

npm install -g @vue/cli 

when i ran commands like vue or vue --version, i received that error message.

This is how i fixed it: I pressed the buttons windows + E, clicked view, checked hidden items. Then, i went to C:\Users\xxxx\AppData\Roaming\npm folder and deleted the vue file of type 'windows powershell script'. After that, i ran the commands vue and vue --version succesfully. Hope this helps.

Denzil Soans
  • 667
  • 1
  • 7
  • 27
  • As an update - I regularly get the error after updating firebase & vue and so delete the relevant .ps file each time without issues as I'm reluctant to alter script settings – Aponting May 20 '20 at 07:06
4

Instead of using PowerShell and changing its security settings, you can simply use cmd instead. It will not give an error and your all commands will run smoothly.

Remember PowerShell is stronger and sensitive. So, Microsoft by default disables running .ps1 files as it can cause a security issue and harm your pc. So, that's why you should try to use cmd instead of changing PowerShell security.

udoyhasan
  • 1,527
  • 5
  • 19
4

Open Powershell from your VS code and then execute this command on that:

set-ExecutionPolicy RemoteSigned -Scope CurrentUser

this worked for me. it will ask you for CLI authentication.

HM Nomaan
  • 131
  • 1
  • 4
3

Open Powershell and execute this command:

set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Reza Rahemtola
  • 1,182
  • 7
  • 16
  • 30
Rak
  • 53
  • 1
  • 5
3

Delete firebase.ps1 located in:

C:\Users\<your account>\AppData\Roaming\npm\

In case you don't have firebase.ps1 delete vue.ps1

enter image description here

Gass
  • 7,536
  • 3
  • 37
  • 41
3

If you have this issue in VS Code, close PowerShell terminal and open a Command Prompt terminal instead.

Dgloria
  • 161
  • 1
  • 12
2
PS C:\> Set-ExecutionPolicy RemoteSigned

It's works for me

hriy
  • 33
  • 1
  • 6
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 06 '21 at 04:54
2

Open powershell on run as administrator.

run this command Set-ExecutionPolicy RemoteSigned as shown:

PS C:\WINDOWS\system32> Set-ExecutionPolicy RemoteSigned

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): A

press Enter.

This fix my problem.

Sunil Sapkota
  • 918
  • 2
  • 11
  • 24
1

I don't know if it can help with Firebase but I had a similar problem installing Vue with *>npm install -g @vue/cli* .

Long story short:
I deleted vue.ps1 from C:\Users\XXX\AppData\Roaming\npm\ and installed it locally (without -g) from powershell terminal inside VsCode *>npm install @vue/cli*.
After that I could use Vue commands without problems.

Giulio Caccin
  • 2,962
  • 6
  • 36
  • 57
lrd1967
  • 49
  • 6
0

Just delete Power Shell file:

C:\Users\<your account>\AppData\Roaming\npm\**vue**

Delete this last vue file, extension of this file is power shall

after delete run command it's work.

Luis Paulo Pinto
  • 5,578
  • 4
  • 21
  • 35
Ars Khatri
  • 44
  • 4
0

I had faced the same problem when i got android studio flamingo update , while working with firebase cli i got the error shown below, enter image description here

that moment i went to the same project directory in my file explorer and opened cmd at the location,

Surprisingly, things worked as normal, My command on normal cmd at same location I then thought that it might be an issue with terminal of my android studio. I checked that my terminal was set to power shell and that was the real cause of the problem .

Change Power-shell to command prompt

so i toggled the terminal as command prompt ,and things again started working as normal.

Same code started working without any error

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Ps066
  • 11
  • 3
-1

On a computer with German as the default language the error might look like:

vue : Die Datei "C:\Program Files\nodejs\vue.ps1" kann nicht geladen werden, da die Ausführung von Skripts auf diesem System deaktiviert ist. Weitere Informationen finden Sie unter "about_Execution_Policies"         
(https:/go.microsoft.com/fwlink/?LinkID=135170).
In Zeile:1 Zeichen:1
+ vue --version
+ ~~~
    + CategoryInfo          : Sicherheitsfehler: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

I had to search for "vue" "PSSecurityException" to find this thread.

I installed a new node version with nvm-windows. Then I installed vue-cli. After that a simple vue --version led to the error above.

It seems like the removal of the vue.ps1 file helped to resolve my problem like some users suggested above.

sebix
  • 39
  • 7
-1

I had a similar issue during installation of grunt and yarn.

"yarn : File C:\AppData\Roaming\npm\yarn.ps1 cannot be loaded. The file C:\AppData\Roaming\npm\yarn.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."

When I checked the AppData\Roaming\npm* folder, I could see grunt script being generated as:

  • Windows Command Script
  • Windows Powershell Script

Upon deletion of the powershell script, the error was gone.

-1

Just open cmd as administrator and go to your project

then execute your firebase command

amJayem
  • 37
  • 1
  • 4
  • You're saying to use `cmd.exe` instead of PowerShell? That has already been suggested by [this answer](https://stackoverflow.com/a/71098500/150605) and [this answer](https://stackoverflow.com/a/67639276/150605), while the question itself acknowledges that possibility with "I can still access firebase scripts if I set my default terminal to cmd." Of course, that doesn't actually fix the problem. – Lance U. Matthews Oct 20 '22 at 04:55
  • @LanceU.Matthews Thanks for your comment. You mentioned two answers and the question acknowledgment where they said about default cmd, not as admin. For this, I added an answer. And I also found this exact error and solved it by cmd admin. – amJayem Oct 20 '22 at 05:57