"Firebase cannot be loading because running scripts is disabled on this system", VSCode on Windows
Asked Answered
C

15

59

I have installed the firebase tools, however whenever I try to initialize it in my rootfolder, using the terminal from Vscode, I receive the following error. Why is that?

enter image description here

Cranial answered 9/3, 2020 at 2:51 Comment(3)
Please check this thread: github.com/firebase/firebase-tools/issues/1627Scrag
Run the commands from simple CMD, worked for me...Fabozzi
Bypassing the execution policy in PowerShell may be dangerous. I recommend to rename the file (to firebase_old.ps1 for example) or to delete it. It is much safer.Adrianadriana
P
94

TLDR: Just delete your firebase.ps1 file and try again

I would not recommend bypassing the execution policy on PowerShell, as it makes your system more vulnerable to malicious scripts.

Instead, simply delete the firebase.ps1 file at the location indicated by the error message and try running the command again.

Note: in case the above doesn't work, you might need to clear your npm cache by running npm cache clean --force.

Prussiate answered 3/7, 2021 at 23:3 Comment(9)
Solved my problem!Birddog
Solved my problem too...Glaucoma
Thanks, @Fappaz, this is a neat and terrific solution! It worked for me as well. It's really not an efficient approach to allow malicious scripts.Krystin
deleting the file solved my problem too! I use the windows 'run' app to acces the file locationSuppository
that should be the answerSyreetasyria
If I already ran the ExecutionPolicy Bypass command before seeing this answer, how do I undo that?Gonidium
@ChristiaanAdams if you ran with scope Process, you can simply close PowerShell as it won't persist. Otherwise, if you ran with some other scope (e.g.: LocalMachine), then you should roll it back by executing Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy UndefinedPrussiate
No one here mentioned where that file is. On windows it's located at: C:\Users\<YourUsername>\AppData\Roaming\npm\firebase.ps1Seat
@DIRTYDAVE The error message provides the exact path to the file right in the beginning, I mention this in my answer.Prussiate
L
83
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

Install firebase globally

npm i -g firebase

and then,

firebase login
firebase init
Lafontaine answered 19/9, 2020 at 3:0 Comment(3)
It works fine...but every time I want to use firebase I had to run this command first...is there any permanent set of execution policy?Ladybug
It looks like to be a per context command. The error goes away after the policy is enabled first on each run, as @ShrishSharma sad.Metamerism
In my case I wanted a run configuration in IntelliJ IDEA to start the Firebase emulator, but I didn't want a global permanent change to the PowerShell policy for security reasons. The trick is to create a run configuration, of type "Shell Script", Execute Type = Script text, and on the Script Text command include both commands separated by semi-colon. E.g.: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass; firebase emulators:start --only "auth,firestore,functions"Teetotal
A
16

Source: https://mcmap.net/q/236599/-powershell-bug-execution-of-scripts-is-disabled-on-this-system

Run the following at the terminal in VS Code (make sure the app is run with the option Running as Administrator as suggested by @MaylorTaylor)

Set-ExecutionPolicy RemoteSigned

Then run the script in that same console.

Atomize answered 9/3, 2020 at 3:16 Comment(2)
Hello, no that did not work but I did run the script on the directory from cmdCranial
You need to run this command in VS Code / Powershell / CMD while the app is "Running as Administrator"Weather
S
9
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

This worked for me

Sabbatarian answered 8/9, 2020 at 18:15 Comment(0)
C
6

Open Windows Power Shell as Administrator and then run the below command to change Execution Policy setting to RemoteSigned

Set-ExecutionPolicy RemoteSigned

Now change directory to your project folder and run the following

firebase login
firebase init
Colorimeter answered 22/10, 2020 at 6:29 Comment(0)
M
2

This worked for me, here are the exact steps:

In VSCode, select Terminal > New Terminal. Next, type cmd. This will switch you from PowerShell to a regular command prompt.

PS C:\Users\user\AndroidStudioProjects\FirebaseMessaging\cloud-functions> cmd
Microsoft Windows [Version 10.0.22621.1848]
(c) Microsoft Corporation. All rights reserved.

C:\Users\user\AndroidStudioProjects\FirebaseMessaging\cloud-functions>firebase login
i  Firebase optionally collects CLI and Emulator Suite usage and error reporting information to help improve our products. Data is collected in accordance with Google's privacy policy (https://policies.google.com/privacy) and is not used to identify you.

? Allow Firebase to collect CLI and Emulator Suite usage and error reporting information? No

Next, your browser should open - follow the Authorization steps. Then:

Waiting for authentication...

+  Success! Logged in as [email protected]
Modern answered 7/7, 2023 at 21:16 Comment(0)
V
1

Close cmd and powershell and VS Code. Then right click on VS code---RunAs Administrator and in the VS Code Terminal run the following command:

Set-ExecutionPolicy Unrestricted

Then in the same VS Code cmd run:

firebase login
firebase init

This should solve your problem. Windows now comes with an extra layer of security to protect your OS environment from random scripts running in the background without admin privilege's. Most Random Scripts(From browser engines on unverified sites and applications) are also bad for your OS,unless you are running them yourself as an admin or as a developer,provided you know what you are doing. Firebase scripts are pretty safe.

Vaclava answered 3/2, 2021 at 18:50 Comment(0)
T
1

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

Run this in your current working directory, i.e where Firebase is initialized and run this command, worked for me.

Tropopause answered 22/3, 2021 at 8:21 Comment(0)
L
1

Instead of setting Execution Policy. I ran windows terminal as administrator instead of VS code terminal and execute command without an issue.

Loot answered 17/10, 2021 at 7:11 Comment(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.Pascoe
P
1

Simply in VScode switch from PowerShell to cmd and type this command.

firebase login

And you will be redirected to your browser to allow Firebase CLI to access the account connected to your firebase project and then type this command.

firebase init 

That should work

Precincts answered 1/11, 2021 at 11:39 Comment(1)
This worked for me, I am using Android Studio and facing the same issue and when i switched to cmd terminal and it is working now. Thanks @Ahmed Abd El-MoezDaina
L
1

In cmd it works

firebase login

firebase init

Select project

Lung answered 9/4, 2022 at 18:24 Comment(0)
A
1

If using VScode, installing the PowerShell extension by Microsoft will solve this issue.

enter link description here

Alcinia answered 26/4, 2022 at 13:7 Comment(0)
J
1

The solution for me: is that i am using Windows 11 and i used to use Windows Power Shell instead of Command Prompt

enter image description here

In case want to use Windows Power Shell you have to run this cmd first:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Jorrie answered 21/12, 2022 at 13:31 Comment(0)
R
0

When you encountered the issue with the Firebase CLI in PowerShell, you were advised to run

Set-ExecutionPolicy RemoteSigned

as an administrator. By executing this command, you would be granting permission to run locally created scripts and would be able to execute the Firebase CLI or other scripts on your system.

It's important to note that changing the execution policy can have security implications. By allowing script execution, you might be exposed to potentially harmful or malicious scripts. Therefore, it's recommended to exercise caution and only change the execution policy if you trust the scripts you intend to run.

Rhine answered 8/6, 2023 at 13:20 Comment(0)
F
0

Instead of running powershell as Admin, run it normally and use the following:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

It is more secured than other answers.

Froe answered 29/9, 2023 at 13:27 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.