70
votes

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.

15
This problem started for several application using npm around November of 2019. It's then that npm started using powershell scripts. See this npm pull request and this subsequent npm issue 470. github.com/npm/cli/issues/470Troy Witthoeft

15 Answers

121
votes

Just delete firebase.ps1 file:

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

92
votes

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

PS C:\> Set-ExecutionPolicy RemoteSigned 

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"
}
40
votes
  1. search for powershell
  2. right click and run as administration
  3. run this simple command Set-ExecutionPolicy RemoteSigned
  4. Press A And Enter
15
votes

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"

12
votes

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

5
votes

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

You could try the following

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted

5
votes

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
4
votes

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.

3
votes

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.

2
votes

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.

0
votes

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.

0
votes

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.

0
votes

Open Powershell and execute this command:

set-ExecutionPolicy RemoteSigned -Scope CurrentUser
-1
votes

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.

-1
votes

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.